الملفات
ghaymah-exam-MohamedSaleh-SRE/app.py
2026-07-26 18:29:34 +00:00

89 أسطر
1.9 KiB
Python

from flask import Flask
import time
app = Flask(__name__)
request_count = 0
@app.before_request
def count_requests():
global request_count
request_count += 1
@app.route("/")
def home():
return f"""
<!DOCTYPE html>
<html>
<head>
<title>Ghaymah Systems API</title>
<style>
body {{
font-family: Arial, sans-serif;
background: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}}
.card {{
background: white;
padding: 40px;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0,0,0,0.2);
text-align: center;
}}
h1 {{
color: #2c3e50;
}}
p {{
color: #555;
font-size: 18px;
}}
a {{
display: inline-block;
margin-top: 20px;
padding: 10px 20px;
background: #007BFF;
color: white;
text-decoration: none;
border-radius: 5px;
}}
a:hover {{
background: #0056b3;
}}
</style>
</head>
<body>
<div class="card">
<h1>🚀 Ghaymah Systems API</h1>
<p>The API is running successfully.</p>
<p><strong>Total Requests:</strong> {request_count}</p>
<a href="/health">Health Check</a>
</div>
</body>
</html>
"""
@app.route("/health")
def health():
return {
"status": "healthy",
"timestamp": int(time.time()),
"requests": request_count
}
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)