-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
45 lines (37 loc) · 1.11 KB
/
main.py
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
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from starlette.middleware.trustedhost import TrustedHostMiddleware
from app.binding import own_router_v1
from app.exceptions import UnexpectedDockerError
from app.handlers.exceptions import handle_docker_exception
from config import Settings
from config import SettingsDependencyMarker
def get_application() -> FastAPI:
application = FastAPI(
debug=True,
title='Docker Utils Microservice',
version='1.0.0',
)
application.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
application.add_middleware(
TrustedHostMiddleware,
allowed_hosts=['*']
)
application.include_router(own_router_v1)
application.dependency_overrides.update(
{
SettingsDependencyMarker: lambda: Settings()
}
)
application.add_exception_handler(
UnexpectedDockerError,
handle_docker_exception
)
return application
app = get_application()