Spaces:
Paused
Paused
| from fastapi import FastAPI | |
| import math | |
| import time | |
| app = FastAPI() | |
| def read_root(): | |
| return {"status": "awake", "message": "The 16GB Engine is hot."} | |
| def do_heavy_math(): | |
| start_time = time.time() | |
| primes = [] | |
| for num in range(2, 50000): | |
| is_prime = True | |
| for i in range(2, int(math.sqrt(num)) + 1): | |
| if (num % i) == 0: | |
| is_prime = False | |
| break | |
| if is_prime: | |
| primes.append(num) | |
| end_time = time.time() | |
| return { | |
| "message": "Heavy job complete in Python", | |
| "primes_found": len(primes), | |
| "seconds_taken": round(end_time - start_time, 2) | |
| } | |