From bc47234f99090ce2185b71b725b439beafa50c87 Mon Sep 17 00:00:00 2001 From: Rolf Niepraschk <Rolf.Niepraschk@ptb.de> Date: Fri, 13 Nov 2020 08:26:38 +0100 Subject: [PATCH] "/", "/index.html", and and some little things --- README.md | 17 +++++++++++++++-- server.py | 16 +++++++++++++++- webapps-deliverer.service | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6b454db..65dc4df 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ # Webapps Deliverer -Flask based web server for delivering file contents of the vaclab web applications. +Flask based web server for delivering file contents of the vaclab web +applications. A proxy is also offered: + +A URL of the form + +``` + http://127.0.0.1:8081/xxxx/vl_db/000_SERVERS +``` + +will be forwarded to the real CouchDB URL + +``` + http://127.0.0.1:xxxx/vl_db/000_SERVERS +``` ## Installation of the server @@ -19,7 +32,7 @@ then activates and starts the systemd process. ## Installation of the data files -The target is this directory structure: +The target has this directory structure: ``` /srv/www/data/ diff --git a/server.py b/server.py index cddf73a..be8b869 100644 --- a/server.py +++ b/server.py @@ -52,7 +52,7 @@ def couchdb_proxy(real_port, p=''): q = request.query_string.decode(); path = p if q: - path = p + '?' + q + path = path + '?' + q host = urlparse(request.base_url).hostname scheme = urlparse(request.base_url).scheme new_url = '{}://{}:{}/{}'.format(scheme, host, real_port, path) @@ -72,6 +72,20 @@ def couchdb_proxy(real_port, p=''): response = Response(resp.content, resp.status_code, headers) return response +@app.route('/') +@app.route('/index.html') +def home(): + return '''<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Webapps Deliverer</title> +</head> +<body> + <h3>VacLab: Combined web and CouchDB proxy service</h3>Version: {} +</body> +</html>'''.format(VERSION) + @app.route('/version') def version(): return VERSION + '\n' diff --git a/webapps-deliverer.service b/webapps-deliverer.service index 8b342cd..635611f 100644 --- a/webapps-deliverer.service +++ b/webapps-deliverer.service @@ -6,7 +6,7 @@ After=network.target User=nobody Environment=FLASK_PORT=8081 Environment=DATA_PATH=/srv/www/data/ -Environment=FLASK_ENV=production +Environment=FLASK_ENV=development Environment=FLASK_DEBUG=1 Type=simple StandardOutput=null -- GitLab