Here are the examples of the python api cherrypy.request.json taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
Source : utils.py
with GNU General Public License v3.0
from SUSE
with GNU General Public License v3.0
from SUSE
def POST(self):
"""
Listen for Prometheus Alertmanager notifications.
"""
notification = cherrypy.request.json
logger.debug('Receiving notification: %s', notification)
self.ctx.telemetry.inc('notifications')
trap_data = parse_notification(self.ctx.config, notification)
if trap_data is not None:
for data in trap_data:
send_snmp_trap(self.ctx.config, data)
self.ctx.telemetry.inc('traps')
2
Source : actuator.py
with MIT License
from dvcorreia
with MIT License
from dvcorreia
def POST(self, **params):
actuator = Actuator()
print(cherrypy.request.json)
if cherrypy.request.json.get("uuid") is not None:
UUIDv4 = re.compile(
r'^[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}$', re.IGNORECASE)
if not UUIDv4.match(cherrypy.request.json.get('uuid')):
return print("Error! uuid " + cherrypy.request.json.get('uuid') + " is not valid")
actuator.uuid = cherrypy.request.json.get('uuid')
if cherrypy.request.json.get('description') is not None:
actuator.description = cherrypy.request.json.get('description')
if cherrypy.request.json.get('username') is not None:
actuator.username = cherrypy.request.json.get('username')
try:
actuator.save()
except Exception as e:
raise cherrypy.HTTPError(400, str(e))
cherrypy.response.status = 201
return {
"status": 201,
"data": actuator.to_json()
}
@cherrypy.tools.json_out()
2
Source : main.py
with MIT License
from JNPRAutomate
with MIT License
from JNPRAutomate
def POST(self, action=None):
if action == 'add':
input_json = cherrypy.request.json
resp = self.my_dev.addNewFlowRoute(flowRouteData=input_json)
return resp
elif action == 'mod':
input_json = cherrypy.request.json
resp = self.my_dev.modFlowRoute(flowRouteData=input_json)
return resp
elif action == 'del':
input_json = cherrypy.request.json
resp = self.my_dev.delFlowRoute(flowRouteData=input_json)
return resp
elif action == 'save':
input_json = cherrypy.request.json
self.my_dev.save_settings(dev_user=input_json['user'], dev_pw=input_json['password'],
age_out_interval=input_json['age_out_interval'])
return True, 'Successfully saved configuration settings'
else:
return False, 'Action not defined'
@cherrypy.expose