{"id":13501931,"url":"https://github.com/sunary/flask-optimize","last_synced_at":"2025-09-25T14:31:23.681Z","repository":{"id":57430557,"uuid":"57305854","full_name":"sunary/flask-optimize","owner":"sunary","description":"Flask optimization: cache, minify html and gzip response","archived":false,"fork":false,"pushed_at":"2023-05-01T20:15:52.000Z","size":35,"stargazers_count":53,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-15T10:13:52.896Z","etag":null,"topics":["flask","gzip-response","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunary.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-04-28T13:55:42.000Z","updated_at":"2023-05-24T20:09:05.000Z","dependencies_parsed_at":"2024-01-18T23:23:59.096Z","dependency_job_id":null,"html_url":"https://github.com/sunary/flask-optimize","commit_stats":{"total_commits":54,"total_committers":4,"mean_commits":13.5,"dds":0.2592592592592593,"last_synced_commit":"b4421c166fd61b357a9666f34ffb1370bffff7e3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunary%2Fflask-optimize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunary%2Fflask-optimize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunary%2Fflask-optimize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunary%2Fflask-optimize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunary","download_url":"https://codeload.github.com/sunary/flask-optimize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234166957,"owners_count":18789961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","gzip-response","python"],"created_at":"2024-07-31T22:01:55.700Z","updated_at":"2025-09-25T14:31:18.349Z","avatar_url":"https://github.com/sunary.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Flask-optimize\n\n[![Build Status](https://travis-ci.org/sunary/flask-optimize.svg?branch=master)](https://travis-ci.org/sunary/flask-optimize)\n\n**Flask optimization using cache, minify html and compress response**\n\nhttps://pypi.python.org/pypi/flask-optimize\n\n## Optimize parameters\n\n### init_app:\n\n**config:** Global config\n\nDefault:\n\n```python\n{\n    'html': {'htmlmin': True,  'compress': True, 'cache': 'GET-84600'},\n    'json': {'htmlmin': False, 'compress': True, 'cache': False},\n    'text': {'htmlmin': False, 'compress': True, 'cache': 'GET-600'}\n}\n```\n\n`html`, `json`, `text`: keys for data type of response, see detail below\n\n**config_update:** update into default global config\n\n### optimize\n\n**dtype:** Data type of response, will get value corresponding with key in global config.\n\n- `html` *(default)* \n- `text`\n- `json`\n\n**htmlmin:** Override `htmlmin` in config by key **dtype**\n\n```\nNone: using default value from global config\nFalse: disable\nTrue: enable minify html\n```\n\n**compress:** Override `compress` in config by key **dtype**\n\n```\nNone: using default value from global config\nFalse: disable\nTrue: enable compress content (using gzip)\n```\n\n**cache:** Override `cache` in config by key **dtype**\n\n```\nNone: using default value from global config\nFalse: disable\ninteger value: enable all method, value is cached period (seconds)\nGET-84600: enable for GET method only, cached period is 84600 seconds\n```\n\n\n## Python code usage\n\n```python\nfrom flask import Flask\nfrom flask_optimize import FlaskOptimize\n\nflask_app = Flask(__name__)\nflask_optimize = FlaskOptimize()\n\n@flask_app.route('/')\n@flask_optimize.optimize()\ndef index():\n    return 'using Flask-optimize'\n\n@flask_app.route('/html')\n@flask_optimize.optimize()\ndef html():\n    return '''\n    \u003chtml\u003e\n    \u003cbody\u003e\n    Default data type is html.\n    This content will be minified.\n    \u003c/body\u003e\n    \u003c/html\u003e\n    '''\n    \n@flask_app.route('/text')\n@flask_optimize.optimize('text')\ndef text():\n    return '''\n    \u003chtml\u003e\n    \u003cbody\u003e\n    Data type response is text, so this content wasn't minified\n    \u003c/body\u003e\n    \u003c/html\u003e\n    '''\n    \n@flask_app.route('/json')\n@flask_optimize.optimize('json')\ndef json():\n    return {'text': 'anything', 'other_values': [1, 2, 3, 4]}\n\nif __name__ == '__main__':\n    flask_app.run('localhost', 8080, debug=True)\n```\n\n## Install\n\n```shell\npip install flask-optimize\n```\n\n## Requirements: ##\n\n* Python 2.x\n* Python 3.x\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunary%2Fflask-optimize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunary%2Fflask-optimize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunary%2Fflask-optimize/lists"}