from flask import Flask
from flask_script import Manager
from App.views import blue
app = Flask(__name__)
app.register_blueprint(blueprint=blue)
manager = Manager(app=app)
if __name__ == '__main__':
manager.run()
vi App/views.py
from flask import Blueprint
blue = Blueprint('first_blue', __name__)
@blue.route('/')
def single_flask():
return "Hello Blueprint"
vi run.sh
python manage.py runserver -d -r -h 0.0.0.0
启动: bash run.sh
地址: http://127.0.0.1:5000/
使用bule即可将项目简单拆分为类似于Django的MVT结构
源码地址:https://github.com/565785929/StudyFlask/tree/master/d06