Created
October 21, 2012 22:48
-
-
Save lost-theory/3928813 to your computer and use it in GitHub Desktop.
flask dynamic url_prefix for blueprints
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, Blueprint, request | |
## blueprint ################################################################## | |
bp = Blueprint('category_functionality', __name__) | |
@bp.route('/') | |
def index(category): | |
return "this is the index page for %r" % category | |
@bp.route('/list') | |
def list(category): | |
return "return a list of %r" % category | |
## app ######################################################################## | |
app = Flask(__name__) | |
app.config['DEBUG'] = True | |
app.register_blueprint(bp, url_prefix="/<path:category>") | |
@app.route("/") | |
def index(): | |
return "index" | |
if __name__ == "__main__": | |
app.run(use_debugger=True, use_reloader=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment