diff --git a/README.md b/README.md index 6b454dbce74e05e7ffef421bd72e5b005961dc08..65dc4dfde5dc920bc4b53cf4f37403dfaacce7ec 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 cddf73a60b43dae28e2bef67d4db7289868e780b..be8b86941eaed8adcb6ec658ff48490bd4a36743 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 8b342cde034515c2bd17c4beb4a7685ad1db7dab..635611fc5dca0cd66f8163fb56b03fd913788059 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