def POST(self): header('Content-Type', 'application/octet-stream') header('Access-Control-Allow-Origin', ctx.env.get('HTTP_ORIGIN')) header('Access-Control-Allow-Headers', ctx.env.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS')) header('Access-Control-Allow-Methods', '*') header('Access-Control-Allow-Credentials', 'true') try: payload = json.loads(data()) # generate entry timestamp payload['timeentry'] = int(time.time()) # guess client IP payload['ip'] = ctx.env.get('HTTP_X_FORWARDED_FOR') if payload['ip'] is None: payload['ip'] = ctx.ip # quand meme, cela peut etre None aussi trace(payload=payload) except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') except Exception as error: print traceback.format_exc() raise InternalError(error) raise Created()
def post(self): """ Trace endpoint used by the XAOD framework to post data access information. .. :quickref: XAODTrace; Send XAOD trace. :<json dict payload: Dictionary contain the trace information. :status 201: Created. :status 400: Cannot decode json data. :status 500: Internal Error. """ try: payload = json.loads(request.data) # generate entry timestamp payload['timeentry'] = int(time.time()) # guess client IP payload['ip'] = request.environ.get('HTTP_X_FORWARDED_FOR') if payload['ip'] is None: payload['ip'] = request.remote_addr trace(payload=payload) except ValueError: return generate_http_error_flask(400, 'ValueError', 'Cannot decode json data') except Exception as error: print traceback.format_exc() return error, 500 return "Created", 201
def post(self): """ Trace endpoint used by the XAOD framework to post data access information. .. :quickref: XAODTrace; Send XAOD trace. :<json dict payload: Dictionary contain the trace information. :status 201: Created. :status 400: Cannot decode json data. :status 500: Internal Error. """ headers = Headers() headers.set('Content-Type', 'application/octet-stream') headers.set('Access-Control-Allow-Origin', request.environ.get('HTTP_ORIGIN')) headers.set('Access-Control-Allow-Headers', request.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS')) headers.set('Access-Control-Allow-Methods', '*') headers.set('Access-Control-Allow-Credentials', 'true') try: payload = json.loads(request.data) # generate entry timestamp payload['timeentry'] = int(time.time()) # guess client IP payload['ip'] = request.headers.get('X-Forwarded-For', default=request.remote_addr) trace(payload=payload) except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list', headers=headers) except Exception as error: print(traceback.format_exc()) return str(error), 500, headers return 'Created', 201, headers
def post(self): """ --- summary: Trace endpoints description: Trace endpoint used by the XAOD framework to post data access information. tags: - Nongrid traces requestBody: content: application/json: schema: type: object properties: payload: description: Dictionary containing the trace information. type: object responses: 201: description: OK content: application/json: schema: type: string enum: ["Created"] 400: description: Cannot decode json data. """ headers = self.get_headers() parameters = json_parameters() # generate entry timestamp parameters['timeentry'] = int(time.time()) # guess client IP parameters['ip'] = request.headers.get('X-Forwarded-For', default=request.remote_addr) trace(payload=parameters) return 'Created', 201, headers
def post(self): """ Trace endpoint used by the XAOD framework to post data access information. .. :quickref: XAODTrace; Send XAOD trace. :<json dict payload: Dictionary contain the trace information. :status 201: Created. :status 400: Cannot decode json data. """ headers = self.get_headers() parameters = json_parameters() # generate entry timestamp parameters['timeentry'] = int(time.time()) # guess client IP parameters['ip'] = request.headers.get('X-Forwarded-For', default=request.remote_addr) trace(payload=parameters) return 'Created', 201, headers