从不同设备进行烧瓶访问 [英] Flask access from different devices

查看:47
本文介绍了从不同设备进行烧瓶访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以生成特定的IP地址或创建烧瓶的特定站点 http://127.0.0.1:5000/站点在本地运行,以访问使用来自其他设备的flask制作的Web应用程序,因为默认情况下它在本地运行,并且在 http://127.0.0.1:5000/但是,我想从其他设备访问它.如果有,请帮忙

Is there a way to generate a specific IP address or make a specific site of flask http://127.0.0.1:5000/ site which runs locally, to access the web-app made using flask from different device as by default it runs locally and under http://127.0.0.1:5000/ but,i want to access it from different devices.If,there's a way please help

推荐答案

请首先参考此

refer first to this doc (section Externally Visible Server) on how to expose your local Flask app to make it accessible from trusted devices in your network for testing purposes.

$(venv) flask run --host=0.0.0.0

或在您的 app.py

from flask import Flask
[..]
app = Flask(__name__)
[..]
if __name__ == "__main__":
   app.run(host="0.0.0.0", port=5000, debug=True)

然后:

$(venv) python app.py

但是如果发生并且您收到此错误拨号TCP 0.0.0.0:5000:connect:连接被拒绝,然后尝试使用本地IP地址( 192.168.xy 而不是托管 Flask 应用程序的计算机的 0.0.0.0 ).您可能会发现此线程很有用

but if it happens and you got this error dial tcp 0.0.0.0:5000: connect: connection refused then try to use the local ip address (192.168.x.y instead of 0.0.0.0) of the machine hosting your Flask app. you may find this thread usefull

这篇关于从不同设备进行烧瓶访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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