Edit Dashboard
هذا الالتزام موجود في:
76
app.py
76
app.py
@@ -1,9 +1,10 @@
|
|||||||
from flask import Flask
|
from flask import Flask, jsonify, send_from_directory
|
||||||
import time
|
import time
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
request_count = 0
|
request_count = 0
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def count_requests():
|
def count_requests():
|
||||||
@@ -12,77 +13,34 @@ def count_requests():
|
|||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
return f"""
|
return """
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Ghaymah Systems API</title>
|
<title>Ghaymah 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>
|
</head>
|
||||||
<body>
|
<body style="font-family:Arial;text-align:center;margin-top:80px;">
|
||||||
|
<h1>🚀 Ghaymah Systems API</h1>
|
||||||
|
|
||||||
<div class="card">
|
<p>Application is running successfully.</p>
|
||||||
<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>
|
|
||||||
|
|
||||||
|
<a href="/health">Health Endpoint</a>
|
||||||
|
<br><br>
|
||||||
|
<a href="/dashboard">Monitoring Dashboard</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@app.route("/dashboard")
|
||||||
|
def dashboard():
|
||||||
|
return send_from_directory("q1-deploy-monitor", "dashboard.html")
|
||||||
|
|
||||||
@app.route("/health")
|
@app.route("/health")
|
||||||
def health():
|
def health():
|
||||||
return {
|
return jsonify({
|
||||||
"status": "healthy",
|
"status": "healthy",
|
||||||
"timestamp": int(time.time()),
|
"uptime": round(time.time() - start_time, 2),
|
||||||
"requests": request_count
|
"requests": request_count
|
||||||
}
|
})
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=5000)
|
app.run(host="0.0.0.0", port=5000)
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
|
|
||||||
COPY app.py .
|
COPY app.py .
|
||||||
|
|
||||||
|
# Copy the dashboard folder
|
||||||
|
COPY q1-deploy-monitor q1-deploy-monitor
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
CMD ["python", "app.py"]
|
CMD ["python", "app.py"]
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ const start=performance.now();
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
const response=await fetch("http://localhost:5000/health");
|
const response=await fetch("/health");
|
||||||
const data=await response.json();
|
const data=await response.json();
|
||||||
|
|
||||||
const latency=(performance.now()-start).toFixed(2);
|
const latency=(performance.now()-start).toFixed(2);
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم