HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/blueprints/api2/restplus.py
import logging

from werkzeug.exceptions import BadRequest
from flask_restx import Api, apidoc
from config import settings

log = logging.getLogger(__name__)

authorizationz = {
    'apikey': {
        'type': 'apiKey',
        'in': 'header',
        'name': 'Authorize'
    }
}

api = Api(version='2.0',
          title='BuyerCall API',
          description='Available API calls',
          authorizations=authorizationz,
          security='apikey')


@api.errorhandler
def default_error_handler(e):
    message = 'An unhandled exception occurred.'
    log.exception(message)

    if not settings.DEBUG:
        return {'message': message}, 500


@api.errorhandler(BadRequest)
def handle_root_exception(e):
    return {'message': 'The browser (or proxy) sent a request that this server could not understand. Please review the request object structure for any inconsistencies.'}, 400