环境门路配置

myblog/├── apps│   ├── cms    #后盾│   │   ├── forms.py  #表单│   │   ├── __init__.py  # init文件│   │   ├── models.py    # 数据库模板文件│   │   └── views.py     # 视图文件│   ├── common  #专用│   │   ├── __init__.py│   │   ├── models.py│   │   └── views.py│   ├── front #前台│   │   ├── forms.py│   │   ├── __init__.py│   │   ├── models.py│   │   └── views.py│   └── __init__.py├── config.py├── myblog.py├── static└── templates

根底布局测试

apps    __init__.py    为空

cms 后盾

apps/cms/views.py #cms业务逻辑

    from flask import Blueprint    bp = Blueprint('cms',__name__,url_prefix='/cms')        @bp.route('/')    def index():        return "cms   page"

apps/cms/__init__.py

    from .views import bp

-----
### common 公共库
apps/common/views.py

    from flask import Blueprint   bp = Blueprint('common',__name__,url_prefix='/common')   @bp.route('/')   def index():       return "common page"

apps/common/__init__.py

    from .views import bp

front 前台

apps/front/views.py

    from flask import Blueprint    bp = Blueprint('front',__name__)    @bp.route('/')    def index():        return "front page"        

config.py 配置文件

DEBUG = True

myblog.py 主程序入口文件

from flask import Flask    from apps.cms import bp as cms_bp    from apps.common import bp as common_bp    from apps.front import bp as front_bp    import config        app = Flask(__name__)    app.config.from_object(config)        app.register_blueprint(cms_bp)     app.register_blueprint(common_bp)     app.register_blueprint(front_bp)         if __name__ == "__main__":        app.run(port=8080,host="0.0.0.0")

原文连贯: https://segmentfault.com/a/11...