-
Notifications
You must be signed in to change notification settings - Fork 66
/
main.py
55 lines (39 loc) · 1.04 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
46
47
48
49
50
51
52
53
54
55
import logging
from fastapi import FastAPI
from app.providers import (
logging_provider,
app_provider,
handle_exception,
pagination_provider,
route_provider,
auth_provider,
)
from config.config import settings
import uvicorn
def create_app() -> FastAPI:
_app = FastAPI()
register(_app, logging_provider)
register(_app, app_provider)
register(_app, handle_exception)
register(_app, pagination_provider)
register(_app, auth_provider)
boot(_app, route_provider)
return _app
def register(_app, provider):
provider.register(_app)
logging.info(provider.__name__ + " registered")
def boot(_app, provider):
provider.boot(_app)
logging.info(provider.__name__ + " booted")
app = create_app()
@app.get("/")
async def root():
return "Welcome to Open Assistant Api"
if __name__ == "__main__":
uvicorn.run(
app="main:app",
host=settings.SERVER_HOST,
port=settings.SERVER_PORT,
workers=settings.SERVER_WORKERS,
reload=settings.ENV == "local",
)