eitaa logo
Code Block
486 دنبال‌کننده
242 عکس
27 ویدیو
2 فایل
Code Block 📱کشف _ تحلیل _ توسعه 💻 کدنویسی _ امنیت _ فناوری
مشاهده در ایتا
دانلود
from flask import Flask, request, render_template_string app = Flask(name) HTML = """ <!DOCTYPE html> <html lang="fa"> <head> <meta charset="UTF-8"> <title>Cyber Lab</title> <style> body { background:; color:; font-family:monospace; padding:30px; } .box { max-width:700px; margin:auto; border:1px solid ; padding:25px; border-radius:12px; } input,button { padding:12px; margin:6px 0; width:100%; background:; color:; border:1px solid ; } </style> </head> <body> <div class="box"> <h1>CYBER LAB</h1> <h3>Search Lab</h3> <form method="GET"> <input name="q" placeholder="ورودی آزمایشی"> <button>Test</button> </form> <p>نتیجه:</p> <div>{{ result|safe }}</div> <hr> <h3>API Lab</h3> <p>/api/user?id=1</p> </div> </body> </html> """ @app.route("/") def index(): result = request.args.get("q", "") return render_template_string(HTML, result=result) @app.route("/api/user") def api_user(): user_id = request.args.get("id", "1") users = { "1": {"name": "Admin", "role": "administrator"}, "2": {"name": "TestUser", "role": "user"} } return users.get( user_id, {"error": "user not found"} ) if name == "main": app.run( host="127.0.0.1", port=5000, debug=False )