Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 698 Bytes

README.md

File metadata and controls

46 lines (33 loc) · 698 Bytes

Type safe HTML DSL for Python

Installation

pip install phtml5

Examples

from phtml5 import *

html_template = html()(
    head()(

    ),
    body()(
        h1()("Hello World!")
    )
)

print(str(html_template))
from sanic import Sanic, Request, HTTPResponse, html as html_response
from phtml5 import *

app = Sanic("Example")

def index_template(name: str):
    return html()(
        head()(

        ),
        body()(
            h1()(f"Hello {name}!")
        )
    )

@app.get("/")
async def index(request: Request) -> HTTPResponse:
    return html_response(str(index_template("Jane")))

if __name__ == "__main__":
    app.run(host="localhost", port=9999)