繁体   English   中英

500内部服务器错误Heroku

[英]500 Internal Server Error Heroku

我有一个用Flask-SQLAlchemy构建的用于学习目的的小系统,并部署在Heroku上(python / postgresql:

http://monkey-me.herokuapp.com/

https://github.com/coolcatDev/monkey-me

我的应用程序在本地运行良好,并且已经通过14个成功通过的测试对它的功能和用例进行了单元测试。

当我部署时,一切似乎都很顺利。 部署它后,我定义环境变量APP_SETTINGS >>> config.BaseConfig,然后运行db_create.py脚本初始化db。 我创建了一些用户:

username-userpassword:

Alex-passwordAlex
Jack-passwordJack
Sara-passwordSara

但是缺少一件事...我从主导航栏转到用户页面,我收到一个5oo内部服务器错误消息:

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

我在app.py上的应用代码具有以下调试模式:

if __name__ == '__main__':
app.run(debug=True)

但是不会显示更多错误。

请注意,如果我访问heroku上的系统并注销,如果我转到``用户身份'',则应该重定向到登录页面,以便进行调试已经走了多远...

如果我在heroku上将环境变量LAUNCHY_DEBUG设置为true或false,一切都会发疯,并且出现新问题...就像我无法删除用户一样,不会加载个人资料图片。...

如果我从heroku中删除LAUNCHY_DEBUG变量,则新问题(无法加载图像,无法删除用户。)在用户页面的原始500错误中仍然存在。

预先感谢您对调试的任何建议

使用以下命令获取更多记录在日志中的反馈:

import logging

app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)

这揭示了问题:

ProgrammingError: (ProgrammingError) column "user_bf.id" must appear in the GROUP BY clause or be used in an aggregate function

修改查询:

 userList = (
            users.query
            .add_column(db.func.count(friendships.user_id).label("total"))
            .add_column(user_bf.id.label("best_friend"))
            .add_column(user_bf.userName.label("best_friend_name"))
            .outerjoin(friendships, users.id == friendships.user_id)
            .outerjoin(user_bf, users.best_friend)
            .group_by(users.id, user_bf.id)
            .order_by(test)
            .paginate(page, 6, False)
        )

关于图像消失:

任何在heroku托管的文件系统上写入的文件都将在生命周期结束时删除。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM