Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Can';t访问ip 0.0.0.0和ip 127.0.0.1_Python_Flask - Fatal编程技术网

Python Can';t访问ip 0.0.0.0和ip 127.0.0.1

Python Can';t访问ip 0.0.0.0和ip 127.0.0.1,python,flask,Python,Flask,代码没有问题,但不起作用 当我更改端口号或关闭防火墙时,同样适用 如果有问题,我很抱歉,因为这个问题是由翻译写的 我已经在网上尝试了很多方法 # file name : index.py # pwd : /project_name/app/main/index.py from flask import Blueprint, request, render_template, flash, redirect, url_for from flask import current_app as a

代码没有问题,但不起作用

当我更改端口号或关闭防火墙时,同样适用

如果有问题,我很抱歉,因为这个问题是由翻译写的

我已经在网上尝试了很多方法

# file name : index.py
# pwd : /project_name/app/main/index.py
 
from flask import Blueprint, request, render_template, flash, redirect, url_for
from flask import current_app as app
 
main= Blueprint('main', __name__, url_prefix='/')

@main.route('/main', methods=['GET'])
def index():
      return render_template('/main/index.html')

理想情况下,表示本地计算机上的所有IPV4地址。但有时情况并非如此(尤其是在windows机器中)

如果您试图启动服务器并访问本地服务器,请尝试

app.run(host="127.0.0.1", port=80)

错误显示获取
/show
时出现问题,因为您没有
.route(“/show”
在您的代码中。您尝试了哪些端口?一些端口可能会被系统阻止。尤其是低于1024的端口。通常代码与Flask使用的默认端口一起工作-
5000
8000
我不确定,但当其他程序已经使用此端口时,您可以得到
错误地址\u无效的
。谢谢您的评论。但是.route('/show')也不起作用。我也使用了80、8000、8080和5000端口,但还没有解决。这很难。(t.t)检查它是否适用于
127.0.0.1
。如果适用,则
0.0.0
的问题与烧瓶无关,而仅与系统有关,它可能需要在不同的位置搜索解决方案-即,或者可能。顺便说一句,您可以使用
路线(“/”
而不是
路线(“/main”)
谢谢你的意见。我试过了,但出现了以下错误:我需要考虑笔记本电脑设置或Wi-Fi是否有问题。127.0.0.1---[21/May/2021 22:37:13]“GET/HTTP/1.1”404-127.0.0.1---[21/May/2021 22:37:14]“GET/favicon.ico HTTP/1.1”404-
<!--file name : index.html-->
<!--pwd : /project_name/app/templates/main/index.html-->
<html>
    <head>
        This is Main page Head
    </head>
    <body>
        This is Main Page Body
    </body>
</html>
# file name : run.py
# pwd : /project_name/run.py
 
from app import app

app.run(host="0.0.0.0", port=80)
 * Serving Flask app "app" (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: off
 * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)

/error code/

http://0.0.0.0:80/ access > ERR_ADDRESS_INVALID
127.0.0.1 - - [21/May/2021 06:41:30] "GET /show HTTP/1.1" 404 -
app.run(host="127.0.0.1", port=80)