def _decorated_view(request, *args, **kwargs):
   try:
     return function(request, *args, **kwargs)
   except Exception as e:
     message = unicode(e)
     code = get_error_code(e)
     if code / 100 == 5:
       print traceback.format_exc()
     return api_response(message, code)
Exemplo n.º 2
0
def query(request):
  params = request.GET
  require_fields(params, ('service', 'query', ('max_count', int)))
  result = algorithms.query(
      params['service'], params['query'], int(params['max_count']))
  return api_response(result)
Exemplo n.º 3
0
def create_service(request):
  params = request.POST
  require_fields(params, ('service'))
  service = service_controllers.create_service(params['service'])
  return api_response(service.token)