Skip to content

0.2.6

Compare
Choose a tag to compare
@eadwinCode eadwinCode released this 01 Jan 10:06
· 880 commits to main since this release
81d250a

What's Changed

  • Documentation Updates by @eadwinCode in #43
  • Reverted building routes from a single list to a list of routers with a well-managed route not found cross routes @eadwinCode in #43
  • Python 3.11 Support by @eadwinCode in #44
  • Changed ASCII drawing to the image by @eadwinCode in #45
  • Added an IExceptionHandler contract for defining custom exception handler by @eadwinCode in #46. Doc
  • Dropped use for BaseHTTPMiddleware from Starlette and added a FunctionBasedMiddleware by @eadwinCode in #47
  • Added file decorator for FileResponseModel and StreamingResponseModel by @eadwinCode in #47
import asyncio
from ellar.common import ModuleRouter, file

async def slow_numbers(minimum: int, maximum: int):
    yield ("<html><body><ul>")
    for number in range(minimum, maximum + 1):
        yield "<li>%d</li>" % number
        await asyncio.sleep(0.01)
    yield ("</ul></body></html>")

router = ModuleRouter('/file')

@router.get()
@file(media_type='text/html')
def file_download():
    return {'path': 'path/to/file.html', 'filename': 'code.html', 'content_disposition_type': 'attachment'}

@router.get('/stream')
@file(media_type='text/html', streaming=True)
def file_stream():
    return slow_numbers(1, 4)

Full Changelog: 0.2.4...0.2.6