Name | naja-atra-jinja JSON |
Version |
1.0.2
JSON |
| download |
home_page | None |
Summary | This is a simple http server, use MVC like design. |
upload_time | 2024-04-03 09:13:46 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2018 Keijack Wu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
http-server
jinja
http
web
web-server
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Jinja for Naja Atra
This is a Jinja extension for [Naja Atra](https://github.com/naja-atra/naja-atra)
## Installation
```
python3 -m pip install naja_atra_jinja
```
## Usage
```python
from naja_atra import route, server
from naja_atra_jinja import JinjaView
@route("/index")
def index(name: str = "world"):
return JinjaView("index.html", {"name": name})
def main():
server.start(port=9090)
if __name__ == "__main__":
main()
```
For the above code, the templates should be placed in the `templates` folder in your project's root.
```
|--templates
|----index.html
|----page.html
|--main.py
```
You can set your own Jinja2 Environment via `set_env` function:
```python
from naja_atra import route, server
from naja_atra_jinja import JinjaView, set_env
from jinja2 import Environment, FileSystemLoader
@route("/index")
def index(name: str = "world"):
return JinjaView("index.html", {"name": name})
def main():
env = Environment(loader=FileSystemLoader("/you/own/template/folder"))
set_env(env)
server.start(port=9090)
if __name__ == "__main__":
main()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "naja-atra-jinja",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "http-server, jinja, http, web, web-server",
"author": null,
"author_email": "keijack <keijack.wu@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/e6/b8/54dbd9135785d994e4c7a8b5c2c6be7ae6cfbfe148442c9b8fceb6d18d34/naja-atra-jinja-1.0.2.tar.gz",
"platform": null,
"description": "# Jinja for Naja Atra\n\nThis is a Jinja extension for [Naja Atra](https://github.com/naja-atra/naja-atra)\n\n## Installation\n\n```\npython3 -m pip install naja_atra_jinja\n```\n\n## Usage\n\n```python\nfrom naja_atra import route, server\nfrom naja_atra_jinja import JinjaView\n\n@route(\"/index\")\ndef index(name: str = \"world\"):\n return JinjaView(\"index.html\", {\"name\": name})\n\ndef main():\n server.start(port=9090)\n\nif __name__ == \"__main__\":\n main()\n\n```\n\nFor the above code, the templates should be placed in the `templates` folder in your project's root. \n\n```\n|--templates\n|----index.html\n|----page.html\n|--main.py\n```\n\nYou can set your own Jinja2 Environment via `set_env` function:\n\n```python\nfrom naja_atra import route, server\nfrom naja_atra_jinja import JinjaView, set_env\nfrom jinja2 import Environment, FileSystemLoader\n\n@route(\"/index\")\ndef index(name: str = \"world\"):\n return JinjaView(\"index.html\", {\"name\": name})\n\ndef main():\n env = Environment(loader=FileSystemLoader(\"/you/own/template/folder\"))\n set_env(env)\n server.start(port=9090)\n\nif __name__ == \"__main__\":\n main()\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2018 Keijack Wu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "This is a simple http server, use MVC like design.",
"version": "1.0.2",
"project_urls": {
"homepage": "https://github.com/naja-atra/naja-atra-jinja",
"repository": "https://github.com/naja-atra/naja-atra-jinja"
},
"split_keywords": [
"http-server",
" jinja",
" http",
" web",
" web-server"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b55ebabede6fa188f8fef61d9d5584e27eaa742e7c4f0f7f2fa6757a2767ab8a",
"md5": "7993bf71d1908e39499218b557d9a935",
"sha256": "929784217f457c8eae0c95b12431d8bd0d21f4be4a3c19c68df59dadeb7d1ccc"
},
"downloads": -1,
"filename": "naja_atra_jinja-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7993bf71d1908e39499218b557d9a935",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4739,
"upload_time": "2024-04-03T09:13:44",
"upload_time_iso_8601": "2024-04-03T09:13:44.822537Z",
"url": "https://files.pythonhosted.org/packages/b5/5e/babede6fa188f8fef61d9d5584e27eaa742e7c4f0f7f2fa6757a2767ab8a/naja_atra_jinja-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e6b854dbd9135785d994e4c7a8b5c2c6be7ae6cfbfe148442c9b8fceb6d18d34",
"md5": "eda2112af89958d8512f6207916575f2",
"sha256": "a7c770f7d93bce494b446c51c9e560fd3a44aeca3492dd598293dd409ea05a63"
},
"downloads": -1,
"filename": "naja-atra-jinja-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "eda2112af89958d8512f6207916575f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 3434,
"upload_time": "2024-04-03T09:13:46",
"upload_time_iso_8601": "2024-04-03T09:13:46.547989Z",
"url": "https://files.pythonhosted.org/packages/e6/b8/54dbd9135785d994e4c7a8b5c2c6be7ae6cfbfe148442c9b8fceb6d18d34/naja-atra-jinja-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-03 09:13:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "naja-atra",
"github_project": "naja-atra-jinja",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "naja-atra-jinja"
}