Reputation: 143
I have a CherryPy service replying with json responses. For this I've implemented the @cherrypy.tools.json_out()
decorator at the top of my class.
I now have one method in the class that needs to respond with an image.
The method sets the cherrypy.response.headers['Content-Type']
corresponding to the image mime-type. It doesn't work if the tools.json_out() decorator is in my code. Without the decorator it works (but than I need to implement all my other methods differently).
I tried setting the tools.json_out()
off in the config of CherryPy with a decorator on the method, but that doesn't overrule it.
What is the problem with my approach?
Thank you for any pointers.
Upvotes: 0
Views: 706
Reputation: 143
I think I found it... Sorry for posting too soon.
I actually added the decorator overruling @cherrypy.config(**{'tools.json_out.on': False})
in the wrong place first.
It needed to be placed in front off the other decorators of the method (@myservice.expose
in my code) .
Now it works.
Hope this info will help somebody else in the future.
Upvotes: 3