Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Flask Path or route parameters add (path)

  • path

  • Accept any path, including slashes:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def main():
    return '''
Main<br>
<a href="/user/name">/user/name</a><br>
<a href="/user/other/dir">/user/other/dir</a><br>
<a href="/user/hi.html">/usre/hi.html</a><br>
'''

@app.route("/user/<path:fullpath>")
def api_info(fullpath):
    return fullpath
FLASK_APP=app.py FLASK_DEBUG=0  flask run