且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将HTTP请求发送到Flask服务器

更新时间:2023-11-27 16:14:04

0.0.0.0表示本地计算机上的所有IPv4地址".这是一个不可路由的元地址.

0.0.0.0 means "all IPv4 addresses on the local machine". It is a meta-address which is non-routable.

如果要本地访问服务器,即与服务器位于同一台计算机上的客户端,请使用IP地址127.0.0.1(环回Internet协议)或等效的域名(本地主机)

If you want to access the server locally, i.e. client on the same machine as the server, either use the IP address 127.0.0.1 (loopback Internet protocol) or the equivalent named domain name (localhost)

r = requests.get('http://127.0.0.1:80')
r = requests.get('http://localhost:80')

如果要从远程计算机(在同一子网上)访问服务器,则可以通过运行服务的服务器IP地址(由路由器/网关分配)连接到服务器

If you are accessing the server from a remote machine (on the same subnet), you can connect to your server through the IP address of server (assigned by your router/gateway) running your service

如果要从远程计算机访问服务器,则可以通过路由器的IP地址连接到服务器.您需要通过适当的端口转发来设置虚拟服务器.

If you are accessing the server from a remote machine otherwise, you can connect to your server through the IP address of your router. You need to set up Virtual servers by appropriate port forwarding.