Fix Bad Gateway: Bind uvicorn to 0.0.0.0 explicitly

هذا الالتزام موجود في:
2026-07-26 15:40:14 +03:00
الأصل 10106651a4
التزام 06f3359de5
4 ملفات معدلة مع 22 إضافات و26 حذوفات

عرض الملف

@@ -2,10 +2,10 @@ FROM python:3.10-slim
WORKDIR /app WORKDIR /app
RUN pip install --no-cache-dir fastapi uvicorn requests RUN pip install --no-cache-dir fastapi uvicorn
COPY . . COPY app.py .
EXPOSE 8000 EXPOSE 8000
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] CMD ["python", "app.py"]

18
app.py
عرض الملف

@@ -1,5 +1,6 @@
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.responses import HTMLResponse from fastapi.responses import HTMLResponse
import uvicorn
import time import time
app = FastAPI() app = FastAPI()
@@ -27,10 +28,9 @@ def health_check():
def get_dashboard(): def get_dashboard():
global request_count global request_count
request_count += 1 request_count += 1
uptime = round(time.time() - start_time, 2) uptime = round(time.time() - start_time, 2)
html_content = f""" return f"""
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ar" dir="rtl"> <html lang="ar" dir="rtl">
<head> <head>
@@ -40,19 +40,15 @@ def get_dashboard():
body {{ font-family: system-ui, sans-serif; background: #0f172a; color: #fff; padding: 40px; text-align: center; }} body {{ font-family: system-ui, sans-serif; background: #0f172a; color: #fff; padding: 40px; text-align: center; }}
.container {{ max-width: 800px; margin: 0 auto; }} .container {{ max-width: 800px; margin: 0 auto; }}
.grid {{ display: flex; gap: 20px; margin-top: 30px; }} .grid {{ display: flex; gap: 20px; margin-top: 30px; }}
.card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }} .card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; }}
.status-up {{ color: #22c55e; font-weight: bold; }} .status-up {{ color: #22c55e; font-weight: bold; }}
h1 {{ font-size: 2.5rem; margin-top: 10px; color: #38bdf8; }} h1 {{ font-size: 2.5rem; color: #38bdf8; }}
p {{ color: #94a3b8; }}
</style> </style>
<script> <script>setTimeout(() => {{ window.location.reload(); }}, 5000);</script>
setTimeout(() => {{ window.location.reload(); }}, 5000);
</script>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h2>🚀 Ghaymah SRE Live Monitoring Dashboard</h2> <h2>🚀 Ghaymah SRE Live Monitoring Dashboard</h2>
<p>تحديث تلقائي كل 5 ثوانٍ</p>
<div class="grid"> <div class="grid">
<div class="card"> <div class="card">
<h3>الحالة (Status)</h3> <h3>الحالة (Status)</h3>
@@ -71,4 +67,6 @@ def get_dashboard():
</body> </body>
</html> </html>
""" """
return html_content
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)

عرض الملف

@@ -2,10 +2,10 @@ FROM python:3.10-slim
WORKDIR /app WORKDIR /app
RUN pip install --no-cache-dir fastapi uvicorn requests RUN pip install --no-cache-dir fastapi uvicorn
COPY . . COPY app.py .
EXPOSE 8000 EXPOSE 8000
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] CMD ["python", "app.py"]

عرض الملف

@@ -1,5 +1,6 @@
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.responses import HTMLResponse from fastapi.responses import HTMLResponse
import uvicorn
import time import time
app = FastAPI() app = FastAPI()
@@ -27,10 +28,9 @@ def health_check():
def get_dashboard(): def get_dashboard():
global request_count global request_count
request_count += 1 request_count += 1
uptime = round(time.time() - start_time, 2) uptime = round(time.time() - start_time, 2)
html_content = f""" return f"""
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ar" dir="rtl"> <html lang="ar" dir="rtl">
<head> <head>
@@ -40,19 +40,15 @@ def get_dashboard():
body {{ font-family: system-ui, sans-serif; background: #0f172a; color: #fff; padding: 40px; text-align: center; }} body {{ font-family: system-ui, sans-serif; background: #0f172a; color: #fff; padding: 40px; text-align: center; }}
.container {{ max-width: 800px; margin: 0 auto; }} .container {{ max-width: 800px; margin: 0 auto; }}
.grid {{ display: flex; gap: 20px; margin-top: 30px; }} .grid {{ display: flex; gap: 20px; margin-top: 30px; }}
.card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }} .card {{ background: #1e293b; padding: 25px; border-radius: 12px; flex: 1; border: 1px solid #334155; }}
.status-up {{ color: #22c55e; font-weight: bold; }} .status-up {{ color: #22c55e; font-weight: bold; }}
h1 {{ font-size: 2.5rem; margin-top: 10px; color: #38bdf8; }} h1 {{ font-size: 2.5rem; color: #38bdf8; }}
p {{ color: #94a3b8; }}
</style> </style>
<script> <script>setTimeout(() => {{ window.location.reload(); }}, 5000);</script>
setTimeout(() => {{ window.location.reload(); }}, 5000);
</script>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h2>🚀 Ghaymah SRE Live Monitoring Dashboard</h2> <h2>🚀 Ghaymah SRE Live Monitoring Dashboard</h2>
<p>تحديث تلقائي كل 5 ثوانٍ</p>
<div class="grid"> <div class="grid">
<div class="card"> <div class="card">
<h3>الحالة (Status)</h3> <h3>الحالة (Status)</h3>
@@ -71,4 +67,6 @@ def get_dashboard():
</body> </body>
</html> </html>
""" """
return html_content
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)