在没有端口的瓶颈请求 [英] Flask request without port in url
问题描述
现在我只是直接运行flask服务器,使用python flask_server.py。
在flask_server.py中:
if __name__ =='__main__':
app.run(host = 0.0.0.0)
$ c $ #flask.Flask.runrel =nofollow> run
方法使用 port 可选参数: if __name__ =='__main__':
app.run(host =0.0.0.0,port = 80)
您可以对此进行测试,但对于生产,我强烈建议您阅读 deployment options 部分,其中详细介绍了使用各种前端WSGI服务器运行瓶子的方法。
<如果您需要帮助了解所有这些组件如何一起工作以及如何设置它们; 这个要点有一个很好的总结。
更新:主机参数必须是一个字符串。
I have an ubuntu EC2 server and want to run a flask server. I want to hit the server using my domain name, api.example.com, without having to include the port number. Right now, I can successfully access the server by doing api.example.com:5000/... but I can't figure out how to do api.example.com/....
Right now I'm just running the flask server directly, using python flask_server.py.
In flask_server.py:
if __name__ == '__main__':
app.run(host=0.0.0.0)
解决方案 The run
method takes a port optional argument:
if __name__ == '__main__':
app.run(host="0.0.0.0", port=80)
You can do this for testing, but for production I highly recommend you read the deployment options section in the documentation which details ways to run flask with various front end WSGI servers.
If you need help understanding how all these components work together and how to set them up; this gist has a nice summary.
Update: The host param needs to be a string.
这篇关于在没有端口的瓶颈请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!