from flask import Blueprint
profile_bp = Blueprint('user',__name__,url_prefix='/user')
# 蓝图、分板块写,方便维护
@profile_bp.route('/')
def info():
return '用户个人信息'
@profile_bp.route('/shop/<id>')
def shop(id):
return '用户购物id{}'.format(id)
from flask import Flask,views
from qs_bp.profile import profile_bp
app = Flask(__name__)
app.register_blueprint(profile_bp)
@app.route('/')
def index():
return '这是index首页'
# 这个是类视图
class ProductView(views.MethodView):
def get(self):
return '商品首页'
def post(self):
# post请求到这
pass
app.add_url_rule('/product',view_func=ProductView.as_view('product_view'))
if __name__ == '__main__':
app.run(debug=True)