You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 line
843 B

  1. from fastapi import FastAPI
  2. from core.config import settings, createAdminAcc
  3. from db.session import engine
  4. from db.base import Base
  5. from apis.base import api_router
  6. from fastapi.middleware.cors import CORSMiddleware
  7. def include_routes(app): # include all routes from our api/v1/
  8. app.include_router(api_router)
  9. def startup(): # start the project, and create the tables
  10. app = FastAPI(
  11. title=settings.PROJECT_NAME,
  12. version=settings.PROJECT_VERSION,
  13. )
  14. Base.metadata.create_all(bind=engine)
  15. createAdminAcc()
  16. include_routes(app)
  17. return app
  18. origins = ['*']
  19. app = startup()
  20. app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=['*'], allow_credentials=True, allow_headers=['*'], expose_headers=['*'])
  21. # Testing stuff
  22. @app.get("/")
  23. def root():
  24. return {"message": "Hello World!"}