项目
在 GitHub 查看
ZeroIntensity/view.py
关于
The Batteries-Detachable Web Framework
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文The Batteries-Detachable Web Framework
This is a work-in-progress!
Installation
It's highly recommended to install from source at the moment:
$ pip install git+https://github.com/zerointensity/view.py
Examples
Simple Hello World
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()
Button Counter
from view.core.app import App
from view.dom.core import html_response
from view.dom.components import page
from view.dom.primitives import button, p
from view.dom.javascript import CompileContext, javascript_compiler
app = App()
@javascript_compiler
def click_button(ctx: CompileContext) -> None:
counter = ctx.document.get_element_by_id("counter")
number = ctx.parse_int(counter.inner_html)
number += 1
counter.inner_html = number
with ctx.condition(number == 42) as condition:
with condition.if_true():
ctx.window.alert("The answer!")
with condition.if_false():
ctx.console.log(number)
@app.get("/")
@html_response
async def home():
with page("Counter"):
yield p("0", id="counter")
yield button("Click me!", onclick=click_button)
app.run()
Copyright
view.py is distributed under the terms of the MIT license.
探索相关项目
加载中…