flask使用wifi ip不能访问,请问怎么解决?
来源:15-8 app.run相关参数与flask配置文件
慕粉1757246390
2019-12-15
您好老师
我目前电脑只连wifi(ip为192.168.1.4没有有线网的情况下我将host不管设置为192.168.1.4还是0.0.0.0都不能通过192.168.1.4:5000/hello打开但可以用127.0.0.1:5000/hello正确打开请问如何解决
我的代码如下
from flask import Flask
author = ‘Justin’
app = Flask(name)
@app.route(’/hello/’)
def hello():
return ‘Hello, Justin’
app.run(host=‘0.0.0.0’, debug=True)
#app.run(host=‘192.168.1.4’, debug=True)
启动环境log如下
E:\study\python\vscode\flask\fisher>python fisher.py
- Serving Flask app “fisher” (lazy loading)
- Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead. - Debug mode: on
- Restarting with stat
- Debugger is active!
- Debugger PIN: 387-432-701
- Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [15/Dec/2019 17:35:50] “[37mGET /hello/ HTTP/1.1[0m” 200 - - Detected change in ‘E:\study\python\vscode\flask\fisher\fisher.py’, reloading
- Restarting with stat
- Debugger is active!
- Debugger PIN: 387-432-701
- Running on http://192.168.1.4:5000/ (Press CTRL+C to quit)
- Detected change in ‘E:\study\python\vscode\flask\fisher\fisher.py’, reloading
- Restarting with stat
- Debugger is active!
- Debugger PIN: 387-432-701
- Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [15/Dec/2019 17:44:28] “[37mGET /hello/ HTTP/1.1[0m” 200 - - Detected change in ‘E:\study\python\vscode\flask\fisher\fisher.py’, reloading
- Restarting with stat
- Debugger is active!
- Debugger PIN: 387-432-701
- Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
127.0.0.1 - - [15/Dec/2019 17:46:18] “[37mGET /hello/ HTTP/1.1[0m” 200 -
127.0.0.1 - - [15/Dec/2019 17:46:35] “[37mGET /hello/ HTTP/1.1[0m” 200 -
127.0.0.1 - - [15/Dec/2019 17:46:49] “[37mGET /hello/ HTTP/1.1[0m” 200 - - Detected change in ‘E:\study\python\vscode\flask\fisher\fisher.py’, reloading
- Restarting with stat
- Debugger is active!
- Debugger PIN: 387-432-701
- Running on http://0.0.0.0:81/ (Press CTRL+C to quit)
127.0.0.1 - - [15/Dec/2019 17:48:16] “[37mGET /hello/ HTTP/1.1[0m” 200 -
写回答
2回答
-
7七月
2019-12-17
没有这个说法。。。挺奇怪的。我看你这也都启动了啊,不应该出现这样的问题,你访问失败的提示是啥
00 -
7七月
2019-12-16
是不是有多个网卡?多个ip?
012019-12-17
相似问题