Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, Query | |
| import os | |
| from typing import Any, Optional | |
| app = FastAPI( | |
| title="Test" | |
| ) | |
| 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 |