29 lines
878 B
Python
29 lines
878 B
Python
import time
|
|
|
|
import uvicorn
|
|
from fastapi import FastAPI, Request, Depends
|
|
from starlette.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
from api.api_v1.api import api_router
|
|
from api.deps import get_current_user
|
|
from core.config import settings
|
|
|
|
app = FastAPI(title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json")
|
|
|
|
allow_anonymous = [f'{settings.API_V1_STR}/{page}' for page in settings.ALLOW_ANONYMOUS]
|
|
allow_anonymous.extend(['/docs'])
|
|
|
|
if settings.BACKEND_CORS_ORIGINS:
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=['*'],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(api_router, prefix=settings.API_V1_STR)
|
|
|
|
if __name__ == '__main__':
|
|
uvicorn.run(app='main:app', host="0.0.0.0", port=8888, reload=True, debug=True)
|