将参数发送到Flask中的蓝图模块

以下是所需的逻辑。索引页面上有一个登录按钮,可将用户带到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-pagesales-start-page

从模块化的角度来看,该信息不应位于auth蓝图中。该信息应仅主应用程序知道。

问题是:有没有办法将这样的参数传递给应用程序__init__.py中的auth蓝图,以便成功后,该蓝图可以重定向到该页面?谢谢

fei89123 回答:将参数发送到Flask中的蓝图模块

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3167513.html

大家都在问