|
- from fastapi import FastAPI
- from core.config import settings, createAdminAcc
- from db.session import engine
- from db.base import Base
- from apis.base import api_router
- from fastapi.middleware.cors import CORSMiddleware
-
-
- def include_routes(app): # include all routes from our api/v1/
- app.include_router(api_router)
-
-
- def startup(): # start the project, and create the tables
- app = FastAPI(
- title=settings.PROJECT_NAME,
- version=settings.PROJECT_VERSION,
- )
- Base.metadata.create_all(bind=engine)
- createAdminAcc()
- include_routes(app)
- return app
-
- origins = ["*"]
- app = startup()
- app.add_middleware(CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"])
-
- # Testing stuff
- @app.get("/")
- def root():
- return {"message": "Hello World!"}
|