使用 SSH 在远程服务器上启动 Flask
Launch Flask on remote server using SSH
我目前正在尝试 运行 在本地安装我的 hello world 应用程序。我希望能够发送朋友的 IP 地址并在我的本地计算机上显示他们的请求。
根据 看来
The IP specified in app.run(host='0.0.0.0') must be owned by your server.
If you want to launch Flask on remote server use SSH.
因为我有 vps 设置 ubuntu,并且我在 ubuntu,有什么办法可以让他在那里发出请求并将其转发给我的本地部署?
Flask 运行 默认在端口 5000 上。如果你想让你的朋友访问你的烧瓶,
- 在 ubuntu VPS 中的
{port_number}
打开 TCP/IP 访问权限。示例:8088
- 在 python 脚本中使用
app.run(host='0.0.0.0', port={port_number})
(app.run(host='0.0.0.0', port=8088))
- 检查您 VPS 的 IP 地址(不是本地 IP)。例如 187.50.128.151
- 在您朋友的计算机上,使用浏览器访问 http://{your_vps_ip}:{port_number} 。示例:http://187.50.128.151:8088
Since I have a vps setup with ubuntu, and I'm on ubuntu...
为什么您的主机 OS 很重要? VPS 是一个完全独立的机器。
is there any way I can have him make the requests there and it forwards it to my local deployment?
如果您有一个 local Flask 实例 不在 VPS 上,那么您想使用 ngrok,你甚至不需要 app.run()
的任何参数,因为你可以 "expose" 通过该工具直接端口 5000。
我目前正在尝试 运行 在本地安装我的 hello world 应用程序。我希望能够发送朋友的 IP 地址并在我的本地计算机上显示他们的请求。
根据
The IP specified in app.run(host='0.0.0.0') must be owned by your server.
If you want to launch Flask on remote server use SSH.
因为我有 vps 设置 ubuntu,并且我在 ubuntu,有什么办法可以让他在那里发出请求并将其转发给我的本地部署?
Flask 运行 默认在端口 5000 上。如果你想让你的朋友访问你的烧瓶,
- 在 ubuntu VPS 中的
{port_number}
打开 TCP/IP 访问权限。示例:8088 - 在 python 脚本中使用
app.run(host='0.0.0.0', port={port_number})
(app.run(host='0.0.0.0', port=8088)) - 检查您 VPS 的 IP 地址(不是本地 IP)。例如 187.50.128.151
- 在您朋友的计算机上,使用浏览器访问 http://{your_vps_ip}:{port_number} 。示例:http://187.50.128.151:8088
Since I have a vps setup with ubuntu, and I'm on ubuntu...
为什么您的主机 OS 很重要? VPS 是一个完全独立的机器。
is there any way I can have him make the requests there and it forwards it to my local deployment?
如果您有一个 local Flask 实例 不在 VPS 上,那么您想使用 ngrok,你甚至不需要 app.run()
的任何参数,因为你可以 "expose" 通过该工具直接端口 5000。