相关疑难解决方法(0)

Heroku gunicorn 烧瓶登录无法正常工作

我有一个使用 Flask-Login 进行身份验证的 Flask 应用程序。使用 Flask 的内置 Web 服务器和在本地运行的 gunicorn,一切都在本地正常工作。但是当它在heroku上时它有问题,有时它会登录我有时不会。当我在导航会话的几秒钟内成功登录时,我的会话就会被破坏并让我自动注销。这应该在用户注销时发生。

在我看来,以下代码片段可能是相关的:

@app.before_request
def before_request():
    g.user = current_user

# I have index (/) and other views (/new) decorated with @login_required
Run Code Online (Sandbox Code Playgroud)

我可能会遇到类似问题,与此。它还没有任何答案,从我从评论中读到的内容来看,作者只是使用python app.py. 那是通过使用 Flask 的内置 Web 服务器。但是,我似乎无法复制他的解决方法,因为app.run(host='0.0.0.0')在端口中运行应用程序,5000并且port=80由于许可,我似乎无法设置。

我没有看到任何对日志有帮助的东西,除了即使我应该验证它也不会进行身份验证。

当我通过身份验证并尝试导航/new/交替直到它注销我时的部分日志:

2016-09-25T06:57:53.052378+00:00 app[web.1]: authenticated - IP:10.179.239.229
2016-09-25T06:57:53.455145+00:00 heroku[router]: at=info method=GET path="/" host=testdep0.herokuapp.com request_id=c7c8f4c9-b003-446e-92d8-af0a81985e72 fwd="124.100.201.61" dyno=web.1 connect=0ms service=116ms status=200 bytes=6526
2016-09-25T06:58:11.415837+00:00 heroku[router]: at=info method=GET path="/new" host=testdep0.herokuapp.com request_id=ae5e4e29-0345-4a09-90c4-36fb64785079 fwd="124.100.201.61" dyno=web.1 connect=0ms …
Run Code Online (Sandbox Code Playgroud)

python heroku flask gunicorn flask-login

5
推荐指数
1
解决办法
1903
查看次数

标签 统计

flask ×1

flask-login ×1

gunicorn ×1

heroku ×1

python ×1