-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathrun.py
More file actions
36 lines (27 loc) · 908 Bytes
/
run.py
File metadata and controls
36 lines (27 loc) · 908 Bytes
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
from dishka import Provider
from dishka.integrations.fastapi import setup_dishka
from fastapi import FastAPI
from app.setup.app_factory import create_ioc_container, create_web_app
from app.setup.config.logs import configure_logging
from app.setup.config.settings import AppSettings, load_settings
def make_app(
*di_providers: Provider,
settings: AppSettings | None = None,
) -> FastAPI:
"""Pass providers to override existing ones for testing."""
if settings is None:
configure_logging()
settings = load_settings()
configure_logging(level=settings.logs.level)
app: FastAPI = create_web_app()
container = create_ioc_container(settings, *di_providers)
setup_dishka(container, app)
return app
if __name__ == "__main__":
import uvicorn
uvicorn.run(
app=make_app(),
port=8000,
reload=False,
loop="uvloop",
)