This is a work-in-progress!
It's highly recommended to install from source at the moment:
$ pip install git+https://github.com/zerointensity/view.py
from view.core.app import App
from view.dom.core import html_response
from view.dom.components import page
from view.dom.primitives import h1
app = App()
@app.get("/")
@html_response
async def home():
with page("Hello, view.py!"):
yield h1("Nobody expects the Spanish Inquisition")
app.run()from view.core.app import App
from view.dom.core import HTMLNode, html_response
from view.dom.components import page
from view.dom.primitives import button, p
from view.javascript import javascript_compiler, as_javascript_expression
app = App()
@javascript_compiler
def click_button(counter: HTMLNode):
yield f"let node = {as_javascript_expression(counter)};"
yield f"let currentNumber = parseInt(node.innerHTML);"
yield f"node.innerHTML = ++currentNumber;"
@app.get("/")
@html_response
async def home():
with page("Counter"):
count = p("0")
yield count
yield button("Click me!", onclick=click_button(count))
app.run()view.py is distributed under the terms of the MIT license.