-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (24 loc) · 859 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
from fastapi import FastAPI, responses
from starlette.middleware.cors import CORSMiddleware
from controllers.users import router as users_router
from controllers.auth import router as auth_router
from config.database import Base, engine
Base.metadata.create_all(bind=engine)
app = FastAPI(title="OTP Authentication via Email")
app.include_router(auth_router, prefix="/api/auth/otp", tags=["AUTH"])
app.include_router(users_router, prefix="/api/users", tags=["USERS"])
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/", include_in_schema=False)
def root():
"""
Redirect the root URL to the API documentation.
Returns:
RedirectResponse: Redirects to the "/docs" URL.
"""
return responses.RedirectResponse(url="/docs")