简体   繁体   English

Python flask 服务器在 Heroku

[英]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),所以基本上最终情况是:

  1. Flask server (socketio on Heroku) Flask 服务器(Heroku 上的 socketio)
  2. Client js on host like (000webhost)主机上的客户端js,例如(000webhost)

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.

相关问题 使用python flask应用程序在heroku上未显示highcharts - highcharts not showing on heroku using python flask app 使用 python flask 的异步服务器消息 - Asynchronous server messages with python flask Heroku node.js和Flask应用程序在本地运行,但不在服务器中运行 - Heroku node.js and Flask application working locally but not in server 尝试将Python /烧瓶应用程序部署到Heroku时无法绑定到$ PORT - Failed to bind to $PORT when trying to deploy Python/flask app to Heroku 如何使用Python / Flask在heroku中显示index.html页面 - How to show index.html page in heroku using Python/Flask 如何从 heroku 上的 json 读取? 使用蟒蛇/烧瓶 - How to read from json on heroku? Using python/flask 如何从客户端 web cam 捕获图像并将其保存到服务器? 我正在使用 Python 和 Flask,在 Heroku 实例上运行 - How can I capture an image from a client side web cam and save it to the server please? I am using Python with Flask, running on a Heroku instance 烧瓶套接字 io heroku 超时 - flask socket io heroku timeout python 和 javascript:如何从 Flask 服务器下载文件 - python and javascript: how to download a file from Flask server 如何在python flask中将服务器IP(Web访问IP)获取为变量 - How to get server ip (web access ip) as a variable in python flask
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM