标签:alt port pre ref == style host src doc
目录结构
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>蓝图渲染</title>
</head>
<body>
<h1>这里是蓝图渲染</h1>
</body>
</html>
子app(创建不同的蓝图,如接口测试、ui测试、性能测试)
from flask import Blueprint
from flask import render_template
interface = Blueprint(‘interface‘, __name__) # 定义一个子app,名为interface(可自定义)
@interface.route(‘/index‘)
def index():
return render_template("interface/index.html")
主程序(注册资app、调蓝图)
from flask import Flask
from interface import interface # 导入对应创建的子app
app = Flask(__name__)
app.register_blueprint(interface, url_prefix=‘/interface‘) # 用子app注册蓝图,url_prefix:访问时会把此内容拼接到host+端口后面
if __name__ == ‘__main__‘:
app.run(
host=‘0.0.0.0‘,
port=8888,
debug=True
)
访问
标签:alt port pre ref == style host src doc
原文地址:https://www.cnblogs.com/zhongyehai/p/10989399.html