25 أسطر
512 B
Python
25 أسطر
512 B
Python
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
|
|
}
|