belyalov / tinyweb

Simple and lightweight HTTP async server for micropython
MIT License
239 stars 40 forks source link

Add support for generators in REST API calls #17

Closed belyalov closed 6 years ago

belyalov commented 6 years ago

Currently, REST API classes whose implements get, post, etc methods have to return dict or string.

Sometimes it is problematic to return relatively big response due to memory constrains. Solution could be add support for generators as it is done for non REST methods.

Like:

class CustomersList():
    async def get(self, data):
        for c in self.customers:
            yield '"customer": {}'.format(c)