Jaymon / endpoints

Lightweight REST api backend framework that automatically maps urls to python modules and classes
MIT License
29 stars 10 forks source link

add a File class #46

Closed Jaymon closed 7 years ago

Jaymon commented 8 years ago

that would automatically set content type and size headers? This feels better to me than having to do this in the controller:

self.response.set_header("Content-Type", MimeType.find_type(filepath))
self.response.set_header("Content-Length", os.path.getsize(filepath))
return open(filepath, "rb")

I would rather just do:

return File(filepath, "rb")

and have endpoints automatically figure everything out and set the correct headers