什么是"app.run(host ='0.0.0.0')"烧瓶中的平均值 [英] What does "app.run(host='0.0.0.0') " mean in Flask

查看:185
本文介绍了什么是"app.run(host ='0.0.0.0')"烧瓶中的平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Flask文档.有人告诉我,使用app.run(host='0.0.0.0'),可以使服务器公开可用.

I am reading the Flask documentation. I was told that with app.run(host='0.0.0.0'), I could make the server publicly available.

是什么意思?我如何在另一台计算机(仅在我自己的计算机中为localhost:5000)中访问服务器?

What does it mean ? How can I visit the server in another computer (just localhost:5000 in my own computer) ?

推荐答案

回答第二个问题.您可以点击烧瓶应用正在运行的机器的IP地址,例如192.168.1.100同一网络上的另一台计算机上的浏览器中,您就在那里.但是,如果您在其他网络上,则将无法访问它.防火墙或VLans可能会导致您无法访问应用程序. 如果该计算机具有公共IP,那么您可以从地球上的任何地方访问该IP,就可以访问该应用程序.通常这可能会强加一些配置,因为大多数公共服务器都位于某种路由器或防火墙的后面.

To answer to your second question. You can just hit the IP address of the machine that your flask app is running, e.g. 192.168.1.100 in a browser on different machine on the same network and you are there. Though, you will not be able to access it if you are on a different network. Firewalls or VLans can cause you problems with reaching your application. If that computer has a public IP, then you can hit that IP from anywhere on the planet and you will be able to reach the app. Usually this might impose some configuration, since most of the public servers are behind some sort of router or firewall.

这篇关于什么是"app.run(host ='0.0.0.0')"烧瓶中的平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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