test-api / main.py
tqhoa's picture
update
191a4fd
raw
history blame
553 Bytes
from fastapi import FastAPI, Query
import os
from typing import Any, Optional
app = FastAPI(
title="Test"
)
@app.get("/")
def root(
show_info: Optional[str] = Query(
False,
description='True/False depending your needs, gets average CPU load value',
regex='^(True|False)$')
) -> Any:
result: Dict[Any, Any] = {
"message": "Your first endpoint is working"
}
if cpu_load == 'True':
result["cpu_average_load"] = os.getloadavg()
result["cpu"] = os.cpu_count()
return result