File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 8
8
- Removed the example of an old json submission (before 2022-11-21)
9
9
- Updated actions using the latest base images and to run using Python 3.9
10
10
- Docker image uses Python 3.11 instead of 3.8
11
+ - Replaced deprecated app "on event" with app lifespan
11
12
### Fixed
12
13
- Updated issue templates
13
14
- Updated a number of libraries to address all current security advisories
Original file line number Diff line number Diff line change 1
1
import json
2
2
import logging
3
3
import re
4
+ from contextlib import asynccontextmanager
4
5
from typing import List
5
6
6
7
import requests
16
17
17
18
LOG = logging .getLogger ("uvicorn.access" )
18
19
19
- app = FastAPI ()
20
20
21
-
22
- @app .on_event ("startup" )
23
- async def startup_event ():
21
+ @asynccontextmanager
22
+ async def lifespan (app_ : FastAPI ):
24
23
LOG = logging .getLogger ("uvicorn.access" )
25
24
console_formatter = uvicorn .logging .ColourizedFormatter (
26
25
"{levelprefix} {asctime} : {message}" , style = "{" , use_colors = True
27
26
)
28
27
LOG .handlers [0 ].setFormatter (console_formatter )
28
+ yield # This is crucial for the lifespan context manager
29
+
30
+
31
+ app = FastAPI (lifespan = lifespan )
29
32
30
33
31
34
@app .get ("/" )
You can’t perform that action at this time.
0 commit comments