diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dc4facf..6ad317b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,7 +29,7 @@ } }, "postAttachCommand": { - "server": "uvicorn --host 0.0.0.0 webapp.main:app --reload" + "server": "/home/vscode/venv/bin/uvicorn --host 0.0.0.0 webapp.main:app --reload" }, "portsAttributes": { "8000": { diff --git a/webapp/main.py b/webapp/main.py index 53b16bc..f61a12f 100644 --- a/webapp/main.py +++ b/webapp/main.py @@ -1,6 +1,7 @@ import json from os.path import dirname, abspath, join from fastapi import FastAPI +from fastapi.responses import RedirectResponse from fastapi.staticfiles import StaticFiles @@ -16,6 +17,14 @@ with open(historical_data, "r") as f: data = json.load(f) +@app.get('/') +def root(): + """ + Allows to open the API documentation in the browser directly instead of + requiring to open the /docs path. + """ + return RedirectResponse(url='/docs', status_code=301) + @app.get('/countries') def countries():