Skip to content

Instantly share code, notes, and snippets.

@longfin
Created January 15, 2012 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save longfin/1616290 to your computer and use it in GitHub Desktop.
Save longfin/1616290 to your computer and use it in GitHub Desktop.
Flask url_for
@app.route('/')
def index():
return ""
@app.route('/<username>')
def show_user(username):
return username
@app.route('/post/<int:post_id>')
def show_post(post_id):
return str(post_id)
from flask import url_for
@app.route("/routes")
def routes():
return "<br />".join([
url_for("index"),
url_for("show_user", username="longfin"),
url_for("show_post", post_id=3)
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment