Skip to content

Support Streaming #30

Open
Open
@raphaeljolivet

Description

@raphaeljolivet

When using Flask Streaming capabilities, flask-compress gathers all the data with get_data() and returns everything at once, breaking the "streaming" paradigm.

You may integrate streaming compression as described in this answer (for deflate here) :
https://stackoverflow.com/a/44387566/254061


def generate_zip():
    compressor = zlib.compressobj()
    for x in range(10000):
        chunk = compressor.compress(f"this is my line: {x}\n".encode())
        if chunk:
            yield chunk
    yield compressor.flush()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions