flask专栏 08.蓝图

08.蓝图

[toc]{type: “ol”, level: [2, 3, 4, 5]}

蓝图使用

#第一步在app中注册蓝图,括号里是一个蓝图对象
app.register_blueprint(user.us)
# 第二步,在不同文件中注册路由时,直接使用蓝图对象注册
# 不用使用app对象,避免了循环导入的问题
from flask import Blueprint
us = Blueprint('user', __name__)
@us.route('/login.html', methods=['GET', "POST"])

中小型项目

项目名字
    -pro_flask文件夹
    -__init__.py
    -templates
        -login.html
    -statics
        -code.png
    -views
        -blog.py
        -account.py
        -user.py
    -run.py

大型项目

项目名
    -pro_flask文件夹
        -__init__.py
        -web
            -__init__.py
            -static
            -views.py
            -templates
        -admin
            -templates
            -static
            -views.py
            -__init__.py
    -run.py
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值