[英]Python flask server on Heroku
i have a python (flask) server, it works locally, but i want to deploy my flask server (socketio) on Heroku, so basically the final situation is:我有一个 python(flask)服务器,它在本地工作,但我想在 Heroku 上部署我的 flask 服务器(socketio),所以基本上最终情况是:
but when i deploy server it does not work但是当我部署服务器时它不起作用
socketio = SocketIO(app, cors_allowed_origins='*')
porta = int(os.environ.get('PORT', 5000))
if __name__ == '__main__':
socketio.run(app, port=porta)
Procfile:档案:
web: python3 server.py
You need to bind to '0.0.0.0' instead of the default ('localhost').您需要绑定到“0.0.0.0”而不是默认值(“localhost”)。 This allows the socketio server to accept external connections.
这允许 socketio 服务器接受外部连接。
socketio.run(host='0.0.0.0', port=porta)
You can see an example of this in a Heroku blog post about Django, another Python web framework: https://blog.heroku.com/python_and_django You can see an example of this in a Heroku blog post about Django, another Python web framework: https://blog.heroku.com/python_and_django
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.