import cProfile
from fasthtml.common import *
from starlette.testclient import TestClient
# Import your FastHTML app and weeks
from app import app, weeks
def profile_app():
"""Profile the FastHTML app!"""
client = TestClient(app)
# Test home page
client.get("/")
# Test 10 weeks (or fewer if less than 5 weeks available)
for week in weeks[: min(10, len(weeks))]:
client.get(f"/week/{week}")
if __name__ == "__main__":
# Run the profiling
cProfile.run("profile_app()", "profile_output.prof")
# python profile_app.py
# snakeviz profile_output.prof