以下是所需的逻辑。索引页面上有一个登录按钮,可将用户带到auth主页,该页面上有用于社交网络的不同社交按钮,例如facebook,twitter等。成功认证后,基于“授权”配置文件(存储在我的应用数据库中)希望将用户重定向到其他主页。
我不熟悉python ,并决定使用烧瓶蓝图。
以下是相关代码
# __init__.py in app directory
....
app = flask(__name__)
...
app.register_blueprint(auth,url_prefix='/auth')
...
以下是蓝图的相关代码
# __init__.py in auth subdirectory within app directory
...
auth = Blueprint('auth',__name__)
...
@auth.route('/')
def login():
return render_template('login.html')
@auth.route('/simplelogin')
def simplelogin():
....
profile = getprofile(user_info["email"])
...
return ??? something
@auth.route('/facebook')
def facebook():
...
....
profile = getprofile(user_info["email"])
...
return ??? something
def getprofile(emailid):
...
return profile
现在,在成功登录现有用户之后,基于配置文件,我希望将页面重定向到特定的起始页面。说出admin-start-page
或sales-start-page
等
从模块化的角度来看,该信息不应位于auth蓝图中。该信息应仅主应用程序知道。
问题是:有没有办法将这样的参数传递给应用程序__init__.py
中的auth蓝图,以便成功后,该蓝图可以重定向到该页面?谢谢