import os from pathlib import Path from flask import Flask, send_from_directory, abort app = Flask(__name__) @app.route("/file/") def get_file(name): if not os.path.exists("/scripts/files/" + name): abort(404) return send_from_directory("/scripts/files", name) if __name__ == '__main__': port = 8080 config_file = Path(__file__).parent / "config.properties" if config_file.exists(): lines = config_file.read_text().splitlines() for line in lines: if "=" not in line: continue key, value = line.split("=", 1) if key == "port": port = int(value) app.run(host='0.0.0.0', port=port)