Commit d3a290a3 authored by Alok Saldanha's avatar Alok Saldanha
Browse files

#6 add GATEWAY_ENABLE_UPLOAD environment variable

routes that modify disk are not added unless the env variable is set.
parent 876538cd
......@@ -65,7 +65,10 @@ Here's what the environment variables mean:
* `CELLXGENE_DATA` - a directory that can contain subdirectories with `.h5ad` data files, *without* trailing slash, e.g. `/mnt/cellxgene_data`
* `GATEWAY_HOST` - the hostname and port that the gateway will run on, typically `localhost:5005` if running locally
* `GATEWAY_PROTOCOL` - typically http when running locally, can be https when deployed if the gateway is behind a load balancer or reverse proxy.
* `GATEWAY_EXTRA_SCRIPTS` - (optional) JSON array of script paths, will be embedded into each page and forwarded with `--scripts` to cellxgene server
* `GATEWAY_IP` - ip addess of instance gateway is running on, mostly used to display SSH instructions
Optional environment variables:
* `GATEWAY_EXTRA_SCRIPTS` - JSON array of script paths, will be embedded into each page and forwarded with `--scripts` to cellxgene server
* `GATEWAY_ENABLE_UPLOAD` - Set to `true` or `1` to enable HTTP uploads. This is not recommended for a public server.
The defaults should be fine if you set up a venv and cellxgene_data folder as above.
......@@ -16,6 +16,7 @@ gateway_protocol = os.environ.get("GATEWAY_PROTOCOL")
ip = os.environ.get("GATEWAY_IP")
extra_scripts = os.environ.get("GATEWAY_EXTRA_SCRIPTS")
ttl = os.environ.get("GATEWAY_TTL")
enable_upload = os.environ.get("GATEWAY_ENABLE_UPLOAD", "").lower() in ['true', '1']
env_vars = {
"CELLXGENE_LOCATION": cellxgene_location,
......@@ -99,10 +99,9 @@ def index():
@app.route("/make_user", methods=["POST"])
def make_user():
dir_name = request.form["directory"]
......@@ -111,7 +110,6 @@ def make_user():
return redirect(location, code=302)
@app.route("/make_subdir", methods=["POST"])
def make_subdir():
parent_path = os.path.join(env.cellxgene_data, request.form["usernames"])
dir_name = request.form["directory"]
......@@ -121,7 +119,6 @@ def make_subdir():
return redirect(location, code=302)
@app.route("/upload_file", methods=["POST"])
def upload_file():
upload_dir = request.form["path"]
......@@ -153,6 +150,11 @@ def upload_file():
return redirect(env.location, code=302)
if env.enable_upload:
app.add_url_rule('/make_user', 'make_user', make_user, methods=["POST"])
app.add_url_rule('/make_subdir', 'make_subdir', make_subdir, methods=["POST"])
app.add_url_rule('/upload_file', 'upload_file', upload_file, methods=["POST"])
def filecrawl():
......@@ -44,10 +44,10 @@
<u>Cache Status: view status of launched cellxgene servers.</u></a>
{% if enable_upload %}
<h1 style="padding-left:35px">
How To Upload Data:
How To Upload Data via HTTP:
<ol style="padding-left:85px;">
......@@ -83,12 +83,12 @@
<li>Take a look at your data using the file crawler link above</li>
{% endif %}
<h1 style="padding-left:35px">
How To Upload Data via SSH and SCP (Linux):
How To Upload Data via SSH and SCP:
<ol style="padding-left:85px;">
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment