Jaymon / endpoints

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

better use for generators, file handlers, and iterators #24

Closed Jaymon closed 7 years ago

Jaymon commented 9 years ago

for wsgi and large files, it would be cool to be able to just return an open file handler or a generator or iterator and wsgi will iterate through it correctly and return it.

I'd like to see this work:

class Foo(Controller):
  def GET(self):
    fp = open("/some/path.ext", 'rb')
    return fp

I'd also love to see support for this working:

class Foo(Controller):
  def GET(self):
    for x in range(100):
      yield x

This would involve modifying the simple server to work similar to uwsgi also, where yield doesn't finish the request like it currently does, I'm cool with that though since we removed Mongrel2 support. This would allow us to get rid of all that hacky generator code also which would simplify Call quite a bit

Jaymon commented 9 years ago

the file pointer portion of this is implemented as of 1.0.27, still need to add generator support