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

all the urls to send file content

parent 55f86855
No related branches found
No related tags found
No related merge requests found
......@@ -10,11 +10,44 @@ app = Flask(__name__)
COUCHDB_PROTO = 'http'
COUCHDB_HOST = '127.0.0.1'
COUCHDB_PORT = '5984'
DB = 'vl_db'
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/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/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/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/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/lib', fn)
## ------------------------------------
## CouchDB Proxy
## from: http://host/5984/foo/bar
## to: http://127.0.0.1:5984/foo/bar
## ------------------------------------
def couchdb_proxy_1(path):
new_url = '{}://{}:{}/{}'.format(COUCHDB_PROTO, COUCHDB_HOST, \
COUCHDB_PORT, path)
......@@ -25,16 +58,14 @@ def couchdb_proxy_1(path):
headers={key: value for (key, value) in request.headers if key != 'Host'},
data=request.get_data(),
cookies=request.cookies,
allow_redirects=False)
headers = [(name, value) for (name, value) in resp.raw.headers.items()]
allow_redirects=False)
excluded_headers = ['content-encoding', 'content-length', \
'transfer-encoding', 'connection']
headers = [(name, value) for (name, value) in resp.raw.headers.items()
if name.lower() not in excluded_headers]
response = Response(resp.content, resp.status_code, headers)
return response
## ------------------------------------
## CouchDB Proxy
## from: http://host/5984/foo/bar
## to: http://127.0.0.1:5984/foo/bar
## ------------------------------------
@app.route('/{}/'.format(COUCHDB_PORT), \
methods=['GET','PUT','POST','HEAD','DELETE','OPTIONS'])
@app.route('/{}/<path:path>'.format(COUCHDB_PORT),
......
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