-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
28 lines (23 loc) · 789 Bytes
/
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
from fastapi import FastAPI
from config.routes import routing
from config.database import engine
from fastapi.staticfiles import StaticFiles
from sqlalchemy.exc import SQLAlchemyError
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(debug=True,docs_url="/api/documentations")
app.add_middleware(CORSMiddleware,
allow_origins=["/"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"]
)
def main():
app.mount("/assets",StaticFiles(directory="public"),name="assets",)
try:
engine.connect()
except SQLAlchemyError as error:
raise error
routing(app)
@app.on_event("startup")
def startUp():
main()