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

code simplified

parent 14cfb44a
No related branches found
No related tags found
No related merge requests found
......@@ -18,33 +18,21 @@ app = Flask(__name__, static_url_path='')
app.url_map.strict_slashes = False
CORS(app)
## =================== URLs to the Web Apps ======================
@app.route('/<fn>', methods=['GET'])
def html(fn):
app.logger.debug('hit html folder: ' + fn)
return send_from_directory(DATA_PATH + '/web-apps', fn)
@app.route('/js/<path:fn>', methods=['GET'])
def js(fn):
app.logger.debug('hit js folder: ' + fn)
return send_from_directory(DATA_PATH + '/web-apps/js', fn)
@app.route('/css/<fn>', methods=['GET'])
def css(fn):
app.logger.debug('hit css folder: ' + fn)
return send_from_directory(DATA_PATH + '/web-apps/css', fn)
@app.route('/img/<fn>', methods=['GET'])
def img(fn):
app.logger.debug('hit img folder: ' + fn)
return send_from_directory(DATA_PATH + '/web-apps/img', fn)
@app.route('/lib/<path:fn>', methods=['GET'])
def lib(fn):
app.logger.debug('hit lib folder: ' + fn)
return send_from_directory(DATA_PATH + '/lib', fn)
'''
=================== URLs for Web Apps ======================
Works for any numbers of sub paths
'''
@app.route('/<p1>', methods=['GET'])
@app.route('/<p1>/<path:p2>', methods=['GET'])
def x(p1, p2=''):
path = p1
if p2:
path = path + '/' + p2
app.logger.debug('hit path: ' + path)
return send_from_directory(DATA_PATH, path)
'''
=================== Proxy for CouchDB access ==============
The following works like a proxy server:
A flask server URL of the form
......@@ -82,7 +70,7 @@ def couchdb_proxy(p=''):
if name.lower() not in excluded_headers]
response = Response(resp.content, resp.status_code, headers)
return response
if __name__ == '__main__':
app.config['ENV'] = FLASK_ENV
app.config['DEBUG'] = FLASK_DEBUG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment