Python网络应用程序无法在Heroku上正常运行吗?

时间:2018-10-28 11:36:36

标签: python heroku websocket socket.io

我试图在Heroku上部署this application。当我在笔记本电脑上本地启动它时,它可以正常运行,但是在将其部署到Heroku上以查看结果后,我遇到了一些问题:我可以在线查看应用程序的整个前端,但是随机数不会动态显示在网页上。 / p>

我不知道如何调试它,因为在我的Heroku控制台上没有错误显示,因此我完全没有任何错误。有什么建议吗?

我的procfile看起来像这样:

web: gunicorn --worker-class eventlet -w 1 orig:app

编辑1: 我打开Goog​​le Chrome控制台后发现:

Mixed Content: The page at 'https://fast-everglades-74376.herokuapp.com/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://fast-everglades-74376.herokuapp.com/socket.io/?EIO=3&transport=websocket&sid=2e9895ef6415455eac51294746b3edf6'. This endpoint should be available via WSS. Insecure access is deprecated.

socket.io.min.js:1 POST http://fast-everglades-74376.herokuapp.com/socket.io/?EIO=3&transport=polling&t=1540729336006-41&sid=f550b39a0e1e4544b1eee0c3f1719871 400 (BAD REQUEST)

此外,在Firefox控制台上,我又遇到了有关混合活动内容的另一个错误

编辑2: 我将Gunicorn模块的版本从19.3更改为18.0,然后尝试在http而不是https上运行页面。在http上它似乎可以运行,问题在于它现在不能在https上运行。

1 个答案:

答案 0 :(得分:2)

关于部署到heroku,您需要安装eventlet才能运行socket-io应用程序。另外,您需要一个Procfile。它基本告诉heroku“ apps”如何运行。在我的示例here中,只需输入那一行:

web: gunicorn -k eventlet python_file:flask_variable_name

在您的示例中,我认为

web: gunicorn -k eventlet application:app

此外,在部署时,请确保从heroku仪表板中添加Procfile并将其设置为“开”。