def on_put(self, req, resp): result = parse(req) resp.status = falcon.HTTP_400 if GeneroValidate().validaPut(req.params) == True: result['id'] = req.params['id'] GeneroDAO().update(result) resp.status = falcon.HTTP_NO_CONTENT resp.content_type = "application/json" resp.set_header('Content-Type', 'application/json')
def on_post(self, req, resp): content = parse(req) valueValidated = GeneroValidate().validaPost(content) if valueValidated == True: GeneroDAO().create(content) resp.status = falcon.HTTP_CREATED else: resp.body = json.dumps(valueValidated) resp.status = falcon.HTTP_400 resp.content_type = "application/json" resp.set_header('Content-Type', 'application/json')