Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-http-server-jinja

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-http-server-jinja

This is a simple http server, use MVC like design.

  • 0.1.1
  • PyPI
  • Socket score

Maintainers
1

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
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:

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()

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc