From f2eb2cad8254b4de91c9356461c96835314bba02 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Wed, 19 Dec 2018 19:20:26 -0500 Subject: [PATCH] Use url_root from Flask rather than hardcoding hostname. (#520) Allows running in a container on a remote host, should also allow running behind a proxy with a url prefix. --- server/app/web/webapp.py | 4 ++-- server/cli/launch.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/app/web/webapp.py b/server/app/web/webapp.py index 2e201e6c..4d0249ca 100644 --- a/server/app/web/webapp.py +++ b/server/app/web/webapp.py @@ -1,5 +1,5 @@ import os -from flask import Blueprint, render_template, send_from_directory, current_app +from flask import Blueprint, render_template, send_from_directory, current_app, request bp = Blueprint("webapp", __name__, template_folder="templates") @@ -7,7 +7,7 @@ bp = Blueprint("webapp", __name__, template_folder="templates") @bp.route("/") def index(): - url_base = current_app.config["CXG_API_BASE"] + url_base = request.url_root + "api/" dataset_title = current_app.config["DATASET_TITLE"] return render_template("index.html", prefix=url_base, datasetTitle=dataset_title) diff --git a/server/cli/launch.py b/server/cli/launch.py index 09260237..787eb402 100644 --- a/server/cli/launch.py +++ b/server/cli/launch.py @@ -117,12 +117,11 @@ def launch( # Setup app cellxgene_url = f"http://{host}:{port}" - api_base = f"{cellxgene_url}/api/" # Import Flask app from server.app.app import app - app.config.update(DATASET_TITLE=title, CXG_API_BASE=api_base) + app.config.update(DATASET_TITLE=title) if not verbose: log = logging.getLogger("werkzeug")