Kitware / tangelo

A simple, quick, powerful web framework
http:/tangelohub.org/tangelo/
Apache License 2.0
185 stars 35 forks source link

Allow returning file objects from a service #530

Closed manthey closed 8 years ago

manthey commented 9 years ago

Currently, if you want to return a file from a service, you have to use a redirect or read the file yourself. If invoke_service returned cherrypy.lib.file_generator instances directly, then you could return a file via return cherrypy.lib.static.serve_file(path, content_type=mime_type), which would be cleaner than using a 302 or 307 redirect. This should be a one line change, but then tests would need to be added.

waxlamp commented 8 years ago

I'd like to handle this similarly to redirects. Something like return tangelo.file("/path/to/file", content_type=..., disposition=..., name=...), which would then do the right thing.