Coverage for app/main.py: 88%
16 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-11-27 09:26 +0000
« prev ^ index » next coverage.py v7.4.1, created at 2024-11-27 09:26 +0000
1import uvicorn
2from fastapi import FastAPI, APIRouter
3from fastapi.responses import RedirectResponse
4from app.delivery_fee.router import delivery_fee_router
5from http import HTTPStatus
8app = FastAPI()
9# Namespace all the routes under /api
10api_root = APIRouter(prefix="/api")
13# Include the delivery_fee_router under /api/delivery
14api_root.include_router(delivery_fee_router, prefix="/delivery")
17# include the root router
18app.include_router(api_root)
21# Redirect requests on root page to /docs page since there is
22# nothing to see on the root page
23@app.get("/")
24async def redirect_to_docs():
25 return RedirectResponse(url="/docs", status_code=HTTPStatus.PERMANENT_REDIRECT)
28def run():
29 uvicorn.run(app, host="127.0.0.1", port=8000)
32if __name__ == "__main__":
33 run()