Python/Flask:ValueError:View函数未返回响应

Python/Flask:ValueError:View函数未返回响应,python,flask,Python,Flask,尽管阅读了文档和教程,但我还是无法解决看似微不足道的问题。不停地咳嗽: builtins.ValueError ValueError: View function did not return a response 每当我尝试渲染我的模板时。使用PyCharm作为编辑器,不会警告任何问题 网站。py: from flask import Flask, url_for, request, render_template app = Flask(__name__, template_folder

尽管阅读了文档和教程,但我还是无法解决看似微不足道的问题。不停地咳嗽:

builtins.ValueError
ValueError: View function did not return a response
每当我尝试渲染我的模板时。使用PyCharm作为编辑器,不会警告任何问题

网站。py:

from flask import Flask, url_for, request, render_template

app = Flask(__name__, template_folder='templates')

@app.route('/')
def hello_world():
    render_template('hello_world.html')

if __name__ == '__main__':

    app.debug = True

    app.run()
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Hello, Flask</title>
</head>
<body>
<h1>Hello, World and Flask!</h1>
</body>
</html>
hello\u world.html:

from flask import Flask, url_for, request, render_template

app = Flask(__name__, template_folder='templates')

@app.route('/')
def hello_world():
    render_template('hello_world.html')

if __name__ == '__main__':

    app.debug = True

    app.run()
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Hello, Flask</title>
</head>
<body>
<h1>Hello, World and Flask!</h1>
</body>
</html>

你好,小瓶子
你好,世界和瓶子!

当然应该

@app.route('/')
def hello_world():
    return render_template('hello_world.html')

插入渲染模板时忽略了“返回”。

您需要改进
hello\u world
方法,如下所示:

返回渲染模板(…)

你看到的错误有点暗示了这一点。Flask期望返回值,但没有看到任何内容