from flask import Flask, render_template_string

app = Flask(__name__)

# 在 app.py 中定义 HTML 模板字符串
html_template = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hello Flask</title>
</head>
<body>
    <h1>Hello, {{ name }}</h1>
</body>
</html>
"""

# 定义路由,渲染 HTML 模板字符串
@app.route('/')
def index():
    return render_template_string(html_template, name='World')

if __name__ == '__main__':
    app.run()