Complete all exam tasks
هذا الالتزام موجود في:
40
q1-deploy-monitor/app.py
Normal file
40
q1-deploy-monitor/app.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from fastapi import FastAPI
|
||||
import time
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
request_count = 0
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def home():
|
||||
global request_count
|
||||
request_count += 1
|
||||
|
||||
return {
|
||||
"message": "Application is running"
|
||||
}
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {
|
||||
"status": "UP"
|
||||
}
|
||||
|
||||
|
||||
@app.get("/stats")
|
||||
def stats():
|
||||
global request_count
|
||||
|
||||
start = time.time()
|
||||
|
||||
request_count += 1
|
||||
|
||||
response_time = round((time.time() - start) * 1000, 2)
|
||||
|
||||
return {
|
||||
"status": "UP",
|
||||
"requests": request_count,
|
||||
"response_time": response_time
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم