This is a simple http server, use MVC like design.
Project description
Jinja for Naja Atra
This is a Jinja extension for Naja Atra
Installation
python3 -m pip install naja_atra_jinja
Usage
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:
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()
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
naja-atra-jinja-1.0.2.tar.gz
(3.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file naja-atra-jinja-1.0.2.tar.gz.
File metadata
- Download URL: naja-atra-jinja-1.0.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7c770f7d93bce494b446c51c9e560fd3a44aeca3492dd598293dd409ea05a63
|
|
| MD5 |
eda2112af89958d8512f6207916575f2
|
|
| BLAKE2b-256 |
e6b854dbd9135785d994e4c7a8b5c2c6be7ae6cfbfe148442c9b8fceb6d18d34
|
File details
Details for the file naja_atra_jinja-1.0.2-py3-none-any.whl.
File metadata
- Download URL: naja_atra_jinja-1.0.2-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 |
929784217f457c8eae0c95b12431d8bd0d21f4be4a3c19c68df59dadeb7d1ccc
|
|
| MD5 |
7993bf71d1908e39499218b557d9a935
|
|
| BLAKE2b-256 |
b55ebabede6fa188f8fef61d9d5584e27eaa742e7c4f0f7f2fa6757a2767ab8a
|