This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""How to gzip a string. | |
This works for Python 3.2. For 3.1-, look at the original gist (under "Revisions") | |
""" | |
import gzip | |
def gzip_str(string_: str) -> bytes: | |
return gzip.compress(string_.encode()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import after_this_request, request | |
from io import BytesIO as IO | |
import gzip | |
import functools | |
def gzipped(f): | |
@functools.wraps(f) | |
def view_func(*args, **kwargs): | |
@after_this_request | |
def zipper(response): |