-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (29 loc) · 915 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
29
30
31
32
33
34
35
36
from fastapi import FastAPI, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import RedirectResponse
from config import settings
from routers import stops, tracking_service
app = FastAPI(
docs_url=settings.BASE_URL + "/docs",
redoc_url=settings.BASE_URL + "/redoc",
openapi_url=settings.BASE_URL + "/openapi.json",
title=settings.API_TITLE,
version=settings.API_VERSION,
)
ALLOWED_ORIGINS = [
"*",
]
app.add_middleware(
CORSMiddleware,
allow_origins=ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(stops.router)
app.include_router(tracking_service.router)
@app.get(settings.BASE_URL, tags=["Docs Redirection"])
def docs_redirection() -> RedirectResponse:
return RedirectResponse(
f'{settings.BASE_URL}/redoc', status_code=status.HTTP_308_PERMANENT_REDIRECT
)