Last active
October 21, 2019 10:43
-
-
Save svieira/3434cbcaf627e50a4808 to your computer and use it in GitHub Desktop.
Example sub-mounted Flask application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, url_for | |
from werkzeug.serving import run_simple | |
from werkzeug.wsgi import DispatcherMiddleware | |
app = Flask(__name__) | |
app.config["APPLICATION_ROOT"] = "/abc/123" | |
@app.route("/") | |
def index(): | |
return "The URL for this page is {}".format(url_for("index")) | |
def simple(env, resp): | |
resp(b'200 OK', [(b'Content-Type', b'text/plain')]) | |
return [b"Hello WSGI World"] | |
parent_app = DispatcherMiddleware(simple, {"/abc/123": app}) | |
if __name__ == "__main__": | |
run_simple('localhost', 5000, parent_app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Flask==0.10.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment