gpt4 book ai didi

python - 为什么flask中的GET请求被调用了两次?

转载 作者:行者123 更新时间:2023-12-04 15:36:26 25 4
gpt4 key购买 nike

<分区>

考虑这个简单的 hello world flask 示例。

from flask import Flask

app = Flask(__name__)

@app.route("/inst")
def index():
print('Hello World!')
return "Hello World!"

if __name__ == '__main__':
app.run(debug=True, use_reloader=False)

当我用路由 url 访问浏览器时,打印语句被执行了两次。控制台输出如下:

* Serving Flask app "main" (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
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [04/Jan/2020 18:22:46] "GET /inst HTTP/1.1" 200 -
Hello World!
Hello World!
127.0.0.1 - - [04/Jan/2020 18:22:46] "GET /inst HTTP/1.1" 200 -

为什么 GET/inst 调用了两次?它应该是这样吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com