Skip to content

Instantly share code, notes, and snippets.

@lost-theory
Created October 21, 2012 22:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lost-theory/3928813 to your computer and use it in GitHub Desktop.
Save lost-theory/3928813 to your computer and use it in GitHub Desktop.
flask dynamic url_prefix for blueprints
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