Beispiel #1
0
        'name': 'X-App-Id'
    },
    'test-app-token': {
        'type': 'apiKey',
        'in': 'header',
        'name': 'X-Token'
    }
})

api = Api(blueprint, version='1.0', doc='/',
          title='客服系统API', description='包括应用后端、客户端和客服端',
          authorizations=authorizations)


# error handlers
api.errorhandler(BizError)(biz_error_handler)
api.errorhandler(NoResultFound)(db_not_found_error_handler)
api.errorhandler(MultipleResultsFound)(db_found_multi_error_handler)


def init_api(app):
    # middleware
    if app.debug:
        from . import debug_middleware

    # jwt
    from . import jwt

    # add namespaces
    if app.debug:
        from .namespaces.bucket.api import api as bucket_api
Beispiel #2
0
from werkzeug.http import HTTP_STATUS_CODES
from werkzeug.utils import secure_filename

from .errors import file_too_large, page_not_found, server_error
from .model import PicBed
from .utils import allowed_file, remove_image

blueprint = Blueprint("api", __name__)
image_api = Api(
    blueprint,
    doc=False,
    version=1.0,
    title="Image API",
    description="Image API for listing images, uploding and removing an image",
)
image_api.errorhandler(RequestEntityTooLarge)(file_too_large)
image_api.errorhandler(NotFound)(page_not_found)
image_api.errorhandler(InternalServerError)(server_error)
upload_parser = image_api.parser()
upload_parser.add_argument("file",
                           location="files",
                           type=FileStorage,
                           required=True)
image_model = image_api.model("image", {
    "img_id": fields.String,
    "img_name": fields.String
})


@image_api.route("/images")
class ImageResourceList(Resource):