forked from premAI-io/prem-daemon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
45 lines (36 loc) · 1.15 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
import os
import sentry_sdk
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from app.core.config import API_PREFIX, DEBUG, PROJECT_NAME
from app.core.events import create_start_app_handler
from app.routes import router as api_router
sentry_sdk.init(
dsn=os.getenv("SENTRY_DSN"),
traces_sample_rate=1.0,
)
def get_application() -> FastAPI:
application = FastAPI(
title=PROJECT_NAME,
debug=DEBUG,
version="0.0.1",
description="Swagger Documentation for Prem Daemon APIs.",
)
application.mount(
"/assets/apps", StaticFiles(directory="./app/assets/"), name="apps"
)
application.include_router(api_router, prefix=API_PREFIX)
application.add_event_handler("startup", create_start_app_handler(application))
application.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
return application
app = get_application()
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000)