方式一:
create_app函数中加入以下两行以进行蓝图注册
from app.api.crawler_task import carwler_task_blue app.register_blueprint(carwler_task_blue,url_prefix='/api/crawler')
接口的__init__.py文件中加入
from flask import Blueprint check_bp = Blueprint('check_bp', __name__) from .api import *
views.py文件中加入
@check_bp.route('check_account',methods=['GET']) def check_user():return 123
方式二:
create_app中加入:
from .article_count import articleCountInformation_blue
app.register_blueprint(articleCountInformation_blue)
接口package的__init__.py文件中加入:
from flask import Blueprint
from flask_restful import Api
from .views import articleCountAPI
articleCountInformation_blue = Blueprint('articleCountInformation',__name__)
api = Api(articleCountInformation_blue)
api.add_resource(articleCountAPI,'/api/article/count')
views.py 文件中加入:
from flask_restful import Resource
class articleCountAPI(Resource):
def get(self):
return 'hello'