25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

31 satır
845 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=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], expose_headers=["*"])
  21. # Testing stuff
  22. @app.get("/")
  23. def root():
  24. return {"message": "Hello World!"}