53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from flask import Blueprint, abort
|
|
from flask_restplus import Api, Namespace
|
|
|
|
api_authorizations = {
|
|
'apikey': {
|
|
'type': 'apiKey',
|
|
'in': 'header',
|
|
'name': 'X-API-KEY'
|
|
},
|
|
'basicAuth': {
|
|
'type': 'basic',
|
|
'scheme': 'basic'
|
|
},
|
|
'bearerAuth': {
|
|
'type': 'apiKey',
|
|
'scheme': 'bearer',
|
|
'name': 'Authorization',
|
|
'in': 'header'
|
|
}
|
|
}
|
|
|
|
api_bp = Blueprint('api', __name__, url_prefix='/api')
|
|
api_v1 = Api(api_bp, prefix="/v1", version='0.1', title='Vue Test API',
|
|
description='The Vue Test API', doc='/v1/doc/', authorizations=api_authorizations, security='bearerAuth')
|
|
|
|
api_user = Namespace('user', description="User management namespace", authorizations=api_authorizations)
|
|
api_group = Namespace('group', description="Group management namespace", authorizations=api_authorizations)
|
|
|
|
api_v1.add_namespace(api_user)
|
|
api_v1.add_namespace(api_group
|
|
)
|
|
|
|
auth_api_bp = Blueprint('auth_api', __name__, url_prefix='/api/auth')
|
|
# user_api_bp = Blueprint('user_api', __name__, url_prefix='/api/user')
|
|
# group_api_bp = Blueprint('group_api', __name__, url_prefix='/api/group')
|
|
|
|
from .example_api import *
|
|
from .auth_api import *
|
|
from .user_api import *
|
|
from .group_api import *
|
|
|
|
|
|
@api_bp.route('/<path:path>')
|
|
def catch_all_api(path):
|
|
"""
|
|
Default 404 response for undefined paths in API.
|
|
:param path:
|
|
:return:
|
|
"""
|
|
abort(404)
|