Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jul 5, 2023
1 parent 3e686cd commit 23aa2fe
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gilda/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,25 @@ def get_app(terms: Optional[GrounderInput] = None, *, ui: bool = True) -> Flask:
app.config['SWAGGER_UI_DOC_EXPANSION'] = 'list'
app.config["grounder"] = Grounder(terms=terms)

if ui:
if not ui:
_mount_home_redirect(app)
else:
try:
from flask_bootstrap import Bootstrap
from gilda.app.ui import ui_blueprint
except ImportError:
@app.route("/")
def home_redirect():
"""Redirect the home url to the API documentation."""
return redirect("/apidocs")
_mount_home_redirect(app)
else:
Bootstrap(app)
app.register_blueprint(ui_blueprint, url_prefix="/")

# has to be put after defining the UI blueprint otherwise it reserves "/"
api.init_app(app)
return app


def _mount_home_redirect(app):
@app.route("/")
def home_redirect():
"""Redirect the home url to the API documentation."""
return redirect("/apidocs")

0 comments on commit 23aa2fe

Please sign in to comment.