Skip to content

Commit

Permalink
fix simple browser start
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredodeza committed Sep 19, 2023
1 parent 378ee7d commit afd196e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
9 changes: 9 additions & 0 deletions webapp/main.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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():
Expand Down

0 comments on commit afd196e

Please sign in to comment.