1、在templates文件夹建立一个html文件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Index</title>
</head>
<body>
<h2>This is index page</h2>
</body>
</html>
2、从flask中导入render_template,整体代码如下:
from flask import Flask, render_template
import config
app = Flask(__name__)
app.config.from_object(config)
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run()
render_template函数会自动在templates文件夹中找到对应的html
标签:__,render,Python,app,Flask,html,template From: https://www.cnblogs.com/QingshanY/p/16793439.html