一、目录结构

二、代码
app.py
from flask import Flask,current_app,request,make_response,render_template
app = Flask(__name__)
@app.route('/test/html')
def test_html():
"""
从文件中响应html
:return:
"""
html = render_template('index.html')
return html
if __name__ == '__main__':
app.run(debug=True)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1 style="color: #0f0"> HTML 文本显示,从文件读取</h1>
</body>
</html>

网友评论