目录结构:
index.py代码:
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('home/index.html', name='h2bcc')
if __name__ == '__main__':
app.run(debug=True)
index.html代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>首页</title>
</head>
<body> Hello,{{name}}!! </body>
</html>
执行index.py结果显示:
按照执行结果提示在浏览器中输入http://127.0.0.1:5000/结果如下: