Skip to content
Snippets Groups Projects
Commit b9ea47c2 authored by Rolf Niepraschk's avatar Rolf Niepraschk
Browse files

version url added ("/version")

parent 14ac1947
No related branches found
No related tags found
No related merge requests found
...@@ -4,15 +4,17 @@ from flask_cors import CORS ...@@ -4,15 +4,17 @@ from flask_cors import CORS
from urllib.parse import urlparse from urllib.parse import urlparse
import sys, requests import sys, requests
app = Flask(__name__) app = Flask(__name__)
VERSION = '1.0.0'
COUCHDB_PROTO = 'http'
COUCHDB_PORT = '5984'
FLASK_RUN_PORT = sys.argv[1] FLASK_RUN_PORT = sys.argv[1]
DATA_PATH = sys.argv[2] DATA_PATH = sys.argv[2]
FLASK_ENV = sys.argv[3] FLASK_ENV = sys.argv[3]
FLASK_DEBUG = sys.argv[4] FLASK_DEBUG = sys.argv[4]
COUCHDB_PROTO = 'http'
COUCHDB_PORT = '5984'
DB = 'vl_db'
app = Flask(__name__, static_url_path='') app = Flask(__name__, static_url_path='')
app.url_map.strict_slashes = False app.url_map.strict_slashes = False
...@@ -28,7 +30,7 @@ def x(p1, p2=''): ...@@ -28,7 +30,7 @@ def x(p1, p2=''):
path = p1 path = p1
if p2: if p2:
path = path + '/' + p2 path = path + '/' + p2
app.logger.debug('hit path: ' + path) app.logger.debug('[path] ' + path)
return send_from_directory(DATA_PATH, path) return send_from_directory(DATA_PATH, path)
''' '''
...@@ -49,10 +51,9 @@ https://stackoverflow.com/questions/6656363/proxying-to-another-web-service-with ...@@ -49,10 +51,9 @@ https://stackoverflow.com/questions/6656363/proxying-to-another-web-service-with
methods=['GET','PUT','POST','HEAD','DELETE','OPTIONS']) methods=['GET','PUT','POST','HEAD','DELETE','OPTIONS'])
def couchdb_proxy(p=''): def couchdb_proxy(p=''):
q = request.query_string.decode(); q = request.query_string.decode();
path = p
if q: if q:
path = p + '?' + q path = p + '?' + q
else:
path = p
host = urlparse(request.base_url).hostname host = urlparse(request.base_url).hostname
new_url = '{}://{}:{}/{}'.format(COUCHDB_PROTO, host, COUCHDB_PORT, path) new_url = '{}://{}:{}/{}'.format(COUCHDB_PROTO, host, COUCHDB_PORT, path)
app.logger.debug('[old couchdb url] ' + request.url) app.logger.debug('[old couchdb url] ' + request.url)
...@@ -71,6 +72,10 @@ def couchdb_proxy(p=''): ...@@ -71,6 +72,10 @@ def couchdb_proxy(p=''):
response = Response(resp.content, resp.status_code, headers) response = Response(resp.content, resp.status_code, headers)
return response return response
@app.route('/version')
def version():
return VERSION + '\n'
if __name__ == '__main__': if __name__ == '__main__':
app.config['ENV'] = FLASK_ENV app.config['ENV'] = FLASK_ENV
app.config['DEBUG'] = FLASK_DEBUG app.config['DEBUG'] = FLASK_DEBUG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment