File size: 1,339 Bytes
75d46f7
 
 
739e275
75d46f7
 
739e275
75d46f7
739e275
75d46f7
4d2d919
 
75d46f7
 
739e275
4d2d919
75d46f7
 
739e275
75d46f7
 
 
 
 
4d2d919
75d46f7
 
 
 
 
 
739e275
75d46f7
4d2d919
 
75d46f7
 
 
4d2d919
75d46f7
 
4d2d919
75d46f7
 
 
 
 
739e275
 
75d46f7
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# import cProfile
# import multiprocessing
# import time

# import requests
# from fasthtml.common import *

# from app import serve, weeks

# PORT = 7860  # Update this to match the port your app is using


# def run_server():
#     serve()  # This should start your FastHTML app


# def make_requests():
#     base_url = f"http://127.0.0.1:{PORT}"

#     # Test home page
#     try:
#         requests.get(f"{base_url}/")
#     except requests.exceptions.RequestException as e:
#         print(f"Error accessing home page: {e}")

#     n_weeks = 10
#     for week in weeks[: min(n_weeks, len(weeks))]:
#         try:
#             requests.get(f"{base_url}/week/{week}")
#         except requests.exceptions.RequestException as e:
#             print(f"Error accessing week {week}: {e}")

#     # Add more requests here to cover other parts of your application


# def profile_app():
#     server_process = multiprocessing.Process(target=run_server)
#     server_process.start()

#     # Wait for the server to start
#     time.sleep(60)

#     try:
#         make_requests()
#     finally:
#         server_process.terminate()
#         server_process.join()


# if __name__ == "__main__":
#     cProfile.run("profile_app()", "profile_output.prof")
#     print("Profiling complete. Run 'snakeviz profile_output.prof' to view results.")