simple-http-server-jinja


Namesimple-http-server-jinja JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryThis is a simple http server, use MVC like design.
upload_time2024-02-18 02:29:28
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT 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 Python Simple Http Server

## What's this?

This is a Jinja extension for pythone simple http server (https://github.com/keijack/python-simple-http-server)

## How to use?

install

```
python3 -m pip install simple_http_server_jinja
```

```python
from simple_http_server import route, server
from simple_http_server_jinja import JinjaView, render

@route("/index")
def index(name: str = "world"):
    return JinjaView("index.html", {"name": name})

@route("/page")
def page():
    return 200, render("page.html", {"a": "b"})

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 simple_http_server import route, server
from simple_http_server_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": "",
    "name": "simple-http-server-jinja",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "http-server,jinja,http,web,web-server",
    "author": "",
    "author_email": "keijack <keijack.wu@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/48/b2/02b0f7a423116842a49a7f6d0821ecc356866ff71c233c663c8196aaf411/simple_http_server_jinja-0.1.1.tar.gz",
    "platform": null,
    "description": "# Jinja for Python Simple Http Server\n\n## What's this?\n\nThis is a Jinja extension for pythone simple http server (https://github.com/keijack/python-simple-http-server)\n\n## How to use?\n\ninstall\n\n```\npython3 -m pip install simple_http_server_jinja\n```\n\n```python\nfrom simple_http_server import route, server\nfrom simple_http_server_jinja import JinjaView, render\n\n@route(\"/index\")\ndef index(name: str = \"world\"):\n    return JinjaView(\"index.html\", {\"name\": name})\n\n@route(\"/page\")\ndef page():\n    return 200, render(\"page.html\", {\"a\": \"b\"})\n\ndef main():\n    server.start(port=9090)\n\nif __name__ == \"__main__\":\n    main()\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 simple_http_server import route, server\nfrom simple_http_server_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": "0.1.1",
    "project_urls": {
        "homepage": "https://github.com/keijack/python-simple-http-server-jinja",
        "repository": "https://github.com/keijack/python-simple-http-server-jinja"
    },
    "split_keywords": [
        "http-server",
        "jinja",
        "http",
        "web",
        "web-server"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6bd0b2e1a207f040f07b9b788511a90d6d12ea42927d8d0664dd9b3c7df03d1",
                "md5": "ea8c628aa74d7276c73dc06d8246a5a9",
                "sha256": "97073847c7afbb0ab3ad57fc9feba39f50909974a92eba89ac0b8d0810660e1a"
            },
            "downloads": -1,
            "filename": "simple_http_server_jinja-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ea8c628aa74d7276c73dc06d8246a5a9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4807,
            "upload_time": "2024-02-18T02:29:26",
            "upload_time_iso_8601": "2024-02-18T02:29:26.383814Z",
            "url": "https://files.pythonhosted.org/packages/e6/bd/0b2e1a207f040f07b9b788511a90d6d12ea42927d8d0664dd9b3c7df03d1/simple_http_server_jinja-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48b202b0f7a423116842a49a7f6d0821ecc356866ff71c233c663c8196aaf411",
                "md5": "4bc9face6bb6d60bf507a59abaee7c73",
                "sha256": "00c538de8638e26544638e02a84396ff39a852013cf709ec40cd20f3b15ec8b9"
            },
            "downloads": -1,
            "filename": "simple_http_server_jinja-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4bc9face6bb6d60bf507a59abaee7c73",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 3402,
            "upload_time": "2024-02-18T02:29:28",
            "upload_time_iso_8601": "2024-02-18T02:29:28.067836Z",
            "url": "https://files.pythonhosted.org/packages/48/b2/02b0f7a423116842a49a7f6d0821ecc356866ff71c233c663c8196aaf411/simple_http_server_jinja-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-18 02:29:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "keijack",
    "github_project": "python-simple-http-server-jinja",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "simple-http-server-jinja"
}
        
Elapsed time: 0.70840s