Python瓶暴露在外部可见 [英] Python flask expose to external visible

查看:205
本文介绍了Python瓶暴露在外部可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这篇文章的帮助下 Flask - 将dev服务器配置为在整个网络中可见,我已经尝试过使我的Flask外部可见,这样我就可以从本地浏览器发送HTTP请求到远程服务器的Flask。



即使我已经打开了连接,有人可以请帮忙,为什么它不为我工作。
我在Putty [脚本在开发服务器]开始我的烧瓶,并尝试从我的Chrome浏览器访问URL HTTP:// [my_sys_ip]:5000 / 即可。 Chrome会向我报告OOPS错误。

Flask 上,我使用 debug 模式关闭:

  if __name__ =='__main__':
app。运行(主机='0.0.0.0',调试=假)

从netstat,我可以看到它听5000:

  netstat -an | grep:5000 
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN

当试图从同一个开发服务器发送一个 GET 请求时,我得到了预期的响应:

  python testing.py 
调用的URL是http://0.0.0.0:5000/
给用户的消息是Hello World !!!!!!!

我缺少什么?

解决方案

我知道这是一个老问题,但我想我会把我的2美分。



从您的描述,听起来就像您通过PuTTY在远程服务器(dev服务器)上启动烧瓶应用程序一样。然后,您尝试访问本地系统上的应用程序(本地主机)。该应用程序没有运行在您的本地系统上,所以这将解释铬的错误。



而不是去 http:// [ my_sys_ip]:5000 ,你需要去 http:// [dev_svr_ip]:5000


With the help of the post Flask - configure dev server to be visible across the network, I have tried the same to make my Flask externally visible so that I can send HTTP requests from my local browser to the Flask in remote server.

Can someone please help on why its not working for me even I have opened the connections. I started my flask in Putty [script in dev server] and tried accessing the URL from my Chrome as http://[my_sys_ip]:5000/. Chrome reports me OOPS error.

On Flask, I have made it externally visble with debug mode turned off:

 if __name__ == '__main__':
    app.run(host='0.0.0.0', debug = False)

From netstat, I can see its listening on 5000:

netstat -an | grep :5000
tcp        0      0 0.0.0.0:5000                0.0.0.0:*                   LISTEN

When tried to send a GET request from the same dev server, I'm successful with the expected response:

python testing.py
URL called is http://0.0.0.0:5000/
Message to the user is Hello World!!!!!!!

What am I missing ?

解决方案

I know this is an old question, but I figured I'll throw my 2 cents in.

From your description, it sounds like you are launching your flask application on a remote server (dev server) through PuTTY. You are then trying to access the app on your local system (localhost). The application isn't running on your local system, so that would explain the error in chrome.

Instead of going to http://[my_sys_ip]:5000, you will need to go to http://[dev_svr_ip]:5000.

这篇关于Python瓶暴露在外部可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆