500内部服务器错误Heroku

编程入门 行业动态 更新时间:2024-10-26 04:25:39
本文介绍了500内部服务器错误Heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have a little system built for learning purposes with Flask-SQLAlchemy and deployed on Heroku(python/postgresql:

monkey-me.herokuapp/

github/coolcatDev/monkey-me

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

My app works fine locally and I have unit tested its functionality and use cases through 14 successfully passed tests.

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

When I deploy everything seems to go perfectly. Its deployed, I define environment variable APP_SETTINGS>>>config.BaseConfig, I run the db_create.py script to initialize the db. I create some users:

username-userpassword: Alex-passwordAlex Jack-passwordJack Sara-passwordSara

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

But one thing is missing...I go to the users page from the main navigation bar and I get a 5oo internal server error saying:

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上的应用代码具有以下调试模式:

My app code on app.py has debug mode on:

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

但不会显示更多错误.

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

Notice that if I access the system on heroku and I am logged out, if I go to Users I am as I should redirected to the login page so thats how far I have gone with the debug...

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

If I set the environment variable LAUNCHY_DEBUG on heroku to either true or false everything goes crazy and new problems appear...like I cant delete a user, the profile images wont load....

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

If I remove the LAUNCHY_DEBUG var from heroku the new problems(images wont load, can't remove user..) persist among the original 500 error of the users page.

提前感谢调试的任何建议

Thanks in advance for any suggestion with the debugging

推荐答案

使用以下内容获取更多写在日志中的反馈:

Use the following to get more feedback written in logs:

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托管的文件系统上编写的文件都将在生命周期结束的dynos上删除.

Any file written on a filesystem hosted on heroku will be deleted on dynos end of lifecycle.

更多推荐

500内部服务器错误Heroku

本文发布于:2023-11-01 22:57:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550655.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   服务器   Heroku

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!