This is a simple http server, use MVC like design.
Project description
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?
from simple_http_server import route, server
from simple_http_server_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
|--main.py
You can set your own Jinja2 Environment via set_env
function:
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file simple_http_server_jinja-0.0.1.tar.gz
.
File metadata
- Download URL: simple_http_server_jinja-0.0.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2775ca7341538b7dc47172303508b33aaf21dc656fb6cd2f74002b9af5aaf8b |
|
MD5 | 118d125a24e5add08f684536ff4a8196 |
|
BLAKE2b-256 | 04c6cfbda5cd5034e06b40bf0d78dc5b7c203d59822c21c365e04d7dd164b2d8 |
File details
Details for the file simple_http_server_jinja-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: simple_http_server_jinja-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a01771e30297617d515b5de9db018858eb7d3440e3c213cc38c43ed14210391 |
|
MD5 | b2fe280428d79fa7f3d4734962b8d82a |
|
BLAKE2b-256 | 3a78df99983cfd800a64bfe819c8d43b59e187a98480971a3f1e7cdd1b339021 |