Flask开发论坛项目实战(1)项目结构搭建

项目结构图:

views.py :

1 from  flask import Blueprint
2 bp = Blueprint("cms",__name__,url_prefix='/admin')
3 
4 @bp.route('/')
5 def index():
6     return '这是后台首页'

 

包内_initt_.py

from .views import bp

 

config.py

DEBUG = True

 

bbs.py

from flask import Flask
from apps.cms import bp as cms_bp
from apps.front import bp as front_bp
from apps.common import bp as common_bp
import config
app = Flask(__name__)
app.config.from_object(config)
app.register_blueprint(cms_bp)
app.register_blueprint(front_bp)
app.register_blueprint(common_bp)

if __name__ == '__main__':
    app.run()

  

 

posted on 2019-03-14 16:38  朗宇  阅读(184)  评论(0编辑  收藏  举报

导航