Skip to content

Instantly share code, notes, and snippets.

@enlore
Last active December 29, 2015 16:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enlore/80bf02346d6cabcba5b1 to your computer and use it in GitHub Desktop.
Save enlore/80bf02346d6cabcba5b1 to your computer and use it in GitHub Desktop.
from flask import Flask, Blueprint, redirect, url_for
### pages blueprint
pages = Blueprint('pages', __name__)
@pages.route('/')
def index():
return 'pages index'
### user blueprint
user = Blueprint('user', __name__)
@user.route('/login')
def login():
return redirect(url_for('pages.index'))
### thuh app
app = Flask(__name__)
app.register_blueprint(user)
app.register_blueprint(pages)
@hussaintamboli
Copy link

when you use url_for('pages.index') which pages?

pages = Blueprint('pages', name)
^^^^^^ (or) ^^^^^

P.S. I landed here from http://stackoverflow.com/questions/19208488/using-url-for-across-blueprints
I am also having similar issue with blueprinting

@holdlg
Copy link

holdlg commented Aug 11, 2015

use app.url_map look result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment