{ "info": { "author": "Endurant Devs", "author_email": "info@endurantdevs.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# sanic-asyncjinja2\nJinja2 in async mode with Sanic [experimental]\n\n[![Build Status](https://img.shields.io/travis/EndurantDevs/sanic-asyncjinja2.svg?logo=travis)](https://travis-ci.org/EndurantDevs/sanic-asyncjinja2) [![Latest Version](https://img.shields.io/pypi/v/sanic-asyncjinja2.svg)](https://pypi.python.org/pypi/sanic-asyncjinja2/) [![Python Versions](https://img.shields.io/pypi/pyversions/sanic-asyncjinja2.svg)](https://github.com/EndurantDevs/sanic-asyncjinja2/blob/master/setup.py) [![Tests Coverage](https://img.shields.io/codecov/c/github/EndurantDevs/sanic-asyncjinja2/master.svg)](https://codecov.io/gh/EndurantDevs/sanic-asyncjinja2)\n\nIt is based on [sanic-jinja2](https://github.com/lixxu/sanic-jinja2). \nIt provides two decorators @template and @stream_template.\nThe main change is in using render_async and generate_async for the decorator functions.\n\n@stream_template is just and experimental way to make HTTP response via sanic.response.stream\nIt gives you ability to decrease time to the first byte on response and stream long response during the processing template with data.\n\n### Example code ###\n```python\nimport asyncio\nfrom sanic import Sanic\nfrom sanic_asyncjinja2 import SanicAsyncJinja2\n\n\napp = Sanic(__name__)\njinja = SanicAsyncJinja2()\njinja.init_app(app)\n\n\n@app.route('/', methods=[\"GET\", ])\n@jinja.template(\"hello.html\")\ndef index(request):\n return {\"name\": \"world\"}\n\n\n@app.route('/slow_query', methods=[\"GET\", ])\n@jinja.template(\"hello.html\")\nasync def slow_handler(request):\n async def func1():\n await asyncio.sleep(2)\n return \"name\"\n\n async def func2():\n await asyncio.sleep(2)\n return \"world\"\n\n async def gfunc(k, v):\n key, value = await asyncio.gather(k, v)\n return {key: value}\n\n f1 = func1()\n f2 = func2()\n g = await gfunc(f1, f2)\n return g\n\n\n# this is just a stupid idea\n# to win the time to the first byte on response\n# on one of our production servers\n# it is helpful with big responses\n@app.route('/simplestream', methods=[\"GET\", ])\n@jinja.stream_template(\"hello.html\")\nasync def handler2(request):\n very_long_text = \"Very long response here...\" \n return {\"name\": \"world\", \"text\": very_long_text}\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/EndurantDevs/sanic-asyncjinja2", "keywords": "sanic-asyncjinja2 sanic jinja2 template", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "sanic-asyncjinja2", "package_url": "https://pypi.org/project/sanic-asyncjinja2/", "platform": "", "project_url": "https://pypi.org/project/sanic-asyncjinja2/", "project_urls": { "Homepage": "https://github.com/EndurantDevs/sanic-asyncjinja2" }, "release_url": "https://pypi.org/project/sanic-asyncjinja2/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Sanic integration with Jinja2 in async mode [experimental]", "version": "0.1.2" }, "last_serial": 4430949, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "5c91e3de927aa3f3b5e89f6aa378c002", "sha256": "46296669dd571fa294cd08ac7e2635626de51dc03f97751f9b88b2b405914b34" }, "downloads": -1, "filename": "sanic-asyncjinja2-0.1.tar.gz", "has_sig": false, "md5_digest": "5c91e3de927aa3f3b5e89f6aa378c002", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3433, "upload_time": "2018-09-21T11:55:56", "url": "https://files.pythonhosted.org/packages/3b/77/2538d613cbbbe61b0ae736c5082379844db3c50529ff5dc498a0a915476c/sanic-asyncjinja2-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "df90d6512ba8156e2246d9fe35251e9d", "sha256": "c39c9d8bf382f4936c61df24dce42745d942acb6014faea036b484b9bbadd4f8" }, "downloads": -1, "filename": "sanic-asyncjinja2-0.1.1.tar.gz", "has_sig": false, "md5_digest": "df90d6512ba8156e2246d9fe35251e9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3595, "upload_time": "2018-09-21T12:05:04", "url": "https://files.pythonhosted.org/packages/3f/b0/dfad483489dc8fba6c77d9b9ceed0079f9dcce119cd701285a3254b45615/sanic-asyncjinja2-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "86bacfd0d6dccb6d37515ec93620bd1f", "sha256": "57d74c5a2a2aeaf02532a8a57396d583778bc3a714482413e2c7d39090a4b281" }, "downloads": -1, "filename": "sanic-asyncjinja2-0.1.2.tar.gz", "has_sig": false, "md5_digest": "86bacfd0d6dccb6d37515ec93620bd1f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3610, "upload_time": "2018-10-30T10:06:49", "url": "https://files.pythonhosted.org/packages/5b/55/32b5860b16ca904a6c9a911c4ca7fe748b82e6a3d21013b3cb6276777683/sanic-asyncjinja2-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "86bacfd0d6dccb6d37515ec93620bd1f", "sha256": "57d74c5a2a2aeaf02532a8a57396d583778bc3a714482413e2c7d39090a4b281" }, "downloads": -1, "filename": "sanic-asyncjinja2-0.1.2.tar.gz", "has_sig": false, "md5_digest": "86bacfd0d6dccb6d37515ec93620bd1f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3610, "upload_time": "2018-10-30T10:06:49", "url": "https://files.pythonhosted.org/packages/5b/55/32b5860b16ca904a6c9a911c4ca7fe748b82e6a3d21013b3cb6276777683/sanic-asyncjinja2-0.1.2.tar.gz" } ] }