-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (34 loc) · 1.12 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
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from starlette.middleware.trustedhost import TrustedHostMiddleware
from app.handlers.exceptions import sql_exception_handler
from app.handlers.models import ExceptionSQL
from app.v1.binding import own_router_v1
from app.v1.files import FileRepository, FileDependencyMarker
from misc import async_session
def get_application_v1() -> FastAPI:
application = FastAPI(
debug=True,
title='Files Hosting',
version='1.2.15',
)
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.add_exception_handler(ExceptionSQL, sql_exception_handler)
application.dependency_overrides.update(
{
FileDependencyMarker: lambda: FileRepository(db_session=async_session),
}
)
return application
app = get_application_v1()