1、主文件
# 导入Flask类
from flask import Flask, Blueprint
from controller.index import user_bp
app = Flask(__name__)
#注册路由
app.register_blueprint(user_bp, url_prefix='/index')
# 装饰器的作用是将路由映射到视图函数index
@app.route('/')
def index():
return '同步程序'
# Flask应用程序实例的run方法启动WEB服务器
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000, debug=True)
路由文件
from flask import Blueprint
user_bp = Blueprint('index', __name__)
@user_bp.route('/')
def user_profile():
return '子路由'
@user_bp.route('/dade')
def dade():
return '之路路由-方法'