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:#080808;
color:#00ff88;
font-family:monospace;
padding:30px;
}
.box {
max-width:700px;
margin:auto;
border:1px solid #00ff88;
padding:25px;
border-radius:12px;
}
input,button {
padding:12px;
margin:6px 0;
width:100%;
background:#111;
color:#00ff88;
border:1px solid #00ff88;
}
</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
)