Spaces:
Paused
Paused
| from flask import Flask, render_template, jsonify | |
| from werkzeug.middleware.dispatcher import DispatcherMiddleware | |
| from werkzeug.serving import run_simple | |
| app = Flask(__name__) | |
| app.secret_key = "change-this-secret-key" # CHANGE THIS - it is public via the bridge | |
| app.config["APPLICATION_ROOT"] = "/app" # matches the public path below | |
| # ----- Your routes, templates, sessions, login logic stay EXACTLY as they are ----- | |
| def index(): | |
| return render_template("index.html") | |
| def status(): | |
| return jsonify({"status": "running", "app": "flask-app"}) | |
| # ------------------------------------------------------------------------------ | |
| if __name__ == "__main__": | |
| # Serve the whole app under the /app prefix so url_for() matches the public path, | |
| # and bind to 0.0.0.0 so the root proxy can reach it. | |
| wrapped = DispatcherMiddleware(Flask("empty"), {"/app": app}) | |
| run_simple("0.0.0.0", 9001, wrapped) |