mounting from env

This commit is contained in:
2024-10-13 17:41:21 -04:00
parent 53956a0be1
commit c023481303
4 changed files with 9 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import json
import werkzeug.exceptions as HTTPerror import werkzeug.exceptions as HTTPerror
import requests import requests
from config import * from config import *
import os
proj = json.load(open("./static/json/projects.json", "r")) proj = json.load(open("./static/json/projects.json", "r"))
books = json.load(open("./static/json/books.json", "r")) books = json.load(open("./static/json/books.json", "r"))
@@ -69,7 +70,9 @@ def hotspotsRIT():
@app.route("/hotspots/<path>") @app.route("/hotspots/<path>")
def hotspotsProxy(path): def hotspotsProxy(path):
return requests.get(f"{HotspotsURL}/{path}").content resp = flask.make_response(requests.get(f"{HotspotsURL}/{path}").content)
resp.headers['Access-Control-Allow-Origin'] = '*' # or restrict to your site's domain
return resp
@app.errorhandler(Exception) @app.errorhandler(Exception)
def page404(e): def page404(e):
@@ -101,10 +104,12 @@ def page404(e):
def static_from_root(): def static_from_root():
return flask.send_from_directory(app.static_folder, flask.request.path[1:]) return flask.send_from_directory(app.static_folder, flask.request.path[1:])
@app.route('/files/<fname>') @app.route('/files/<path:fname>')
def filesystem_send(fname): def filesystem_send(fname):
print(app.static_folder + "files/") safe_path = os.path.abspath(os.path.join("/mnt/readonly/", fname))
return flask.send_from_directory(app.static_folder + '/files/', fname) if not safe_path.startswith("/mnt/readonly/"):
return "Invalid path", 400
return flask.send_from_directory("/mnt/readonly/", fname)
if __name__ == "__main__": if __name__ == "__main__":

Binary file not shown.