Initial commit for Ghaymah SRE Exam
هذا الالتزام موجود في:
24
q1-deploy-monitor/app.py
Normal file
24
q1-deploy-monitor/app.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from fastapi import FastAPI
|
||||
import time
|
||||
|
||||
app = FastAPI()
|
||||
start_time = time.time()
|
||||
request_count = 0
|
||||
|
||||
@app.middleware("http")
|
||||
def count_requests(request, call_next):
|
||||
global request_count
|
||||
request_count += 1
|
||||
return call_next(request)
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"message": "Welcome to Ghaymah SRE Service"}
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {
|
||||
"status": "healthy",
|
||||
"uptime_seconds": round(time.time() - start_time, 2),
|
||||
"total_requests": request_count
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم