python - Easiest way to find if a GET request does not find a resource -


in python-eve framework, easiest way find in post hook request failed find resources (for example, given filtering parameters failed match resources)?

thanks!

since payload flask response object, can take profit of features. 1 option investigate _items key, which, on collection endpoint, returns actual documents:

import json  def on_post_get(resoure, request, payload):     # actual response json out of flask response     json = json.loads(payload.get_data())      documents = json['_items']     assert(len(documents) == 0)  app = eve() app.on_post_get += on_post_get  if __name__ == '__main__':     app.run() 

Comments