Skip to content

Commit

Permalink
redirect swagger as home
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmajestic committed Feb 24, 2024
1 parent dd5de28 commit b90cc0f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions odds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import FastAPI
from fastapi.openapi.models import Info
from fastapi.openapi.models import ExternalDocumentation
from fastapi.responses import RedirectResponse
import requests
from dotenv import load_dotenv
import os
Expand Down Expand Up @@ -39,7 +40,15 @@
),
)

@app.get("/", summary="Get Sports Data")
@app.get("/", include_in_schema=False)
async def redirect_to_docs():
"""
Redirect to the documentation.
"""
response = RedirectResponse(url='/docs')
return response

@app.get("/sports", summary="Get Sports Data")
async def get_sports():
"""
Retrieve sports data from the Odds API.
Expand All @@ -56,4 +65,4 @@ async def get_sports():
return {"error": "Failed to fetch data from the Odds API"}

if __name__ == "__odds__":
uvicorn.run(app, host="0.0.0.0", port=8885)
uvicorn.run(app, host="0.0.0.0", port=8885)

0 comments on commit b90cc0f

Please sign in to comment.