🐍 Flask App

کد Flask شما با موفقیت آپلود شد.
برای اجرای این کد، روی سرور خودتون (یا هر میزبان Flask) فایل app.py بسازید و کد زیر رو داخلش بذارید، سپس python app.py رو اجرا کنید.
from flask import Flask, jsonify

app = Flask(name)

@app.route("/")
def home():
    return """
    <!DOCTYPE html>
    <html lang="fa">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Flask Demo</title>
        <style>
            body {
                margin: 0;
                min-height: 100vh;
                display: flex;
                align-items: center;
                justify-content: center;
                background: #050505;
                color: #00ff88;
                font-family: Arial, sans-serif;
            }

            .box {
                padding: 35px;
                border: 1px solid #00ff88;
                border-radius: 20px;
                background: #0b0b0b;
                box-shadow: 0 0 30px #00ff8844;
                text-align: center;
            }

            button {
                padding: 12px 25px;
                border: 0;
                border-radius: 12px;
                background: #00ff88;
                color: #000;
                font-weight: bold;
                cursor: pointer;
            }
        </style>
    </head>
    <body>
        <div class="box">
            <h1>⚡ Flask Online</h1>
            <p>سرور با موفقیت اجرا شد.</p>
            <button onclick="testAPI()">Test API</button>
            <p id="result"></p>
        </div>

        <script>
            async function testAPI() {
                const res = await fetch("/api/status");
                const data = await res.json();
                document.getElementById("result").textContent =
                    data.message;
            }
        </script>
    </body>
    </html>
    """

@app.route("/api/status")
def status():
    return jsonify({
        "status": "online",
        "message": "API با موفقیت کار می‌کند ⚡"
    })

if name == "main":
    app.run(host="0.0.0.0", port=5000, debug=True)