« Back to Search  |  Reader Mode  |  Switch to Full Retro Site View Links: Stay in Reader  |  Retro Mode: ON  |  Original »
GitHub · Extracted in 779 ms

GitHub - ZeroIntensity/view.py: The Batteries-Detachable Web Framework

Source: https://github.com/ZeroIntensity/view.py

Repository navigation

view.py
Public

About

The Batteries-Detachable Web Framework

view.zintensity.dev

Topics

python web

Resources

Readme MIT license Activity

Stars

210 stars

Watchers

2 watching

Forks

17 forks Report repository
Branches

Tags
Go to Branches page Go to Tags page

Latest commit

 

History


1,074 Commits
View commit history for this file.

Folders and files

Name Name Last commit message Last commit date
.github .github    
docs docs    
logos logos    
src/ view src/ view    
tests tests    
.gitattributes .gitattributes    
.gitignore .gitignore    
.pre-commit-config.yaml .pre-commit-config.yaml    
CHANGELOG.md CHANGELOG.md    
LICENSE LICENSE    
README.md README.md    
hatch.toml hatch.toml    
netlify.toml netlify.toml    
pyproject.toml pyproject.toml    
requirements.txt requirements.txt    
runtime.txt runtime.txt    

Repository files navigation

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.

About

The Batteries-Detachable Web Framework

view.zintensity.dev

Topics

python web

Resources

Readme MIT license Activity

Stars

210 stars

Watchers

2 watching

Forks

17 forks Report repository

Releases

Sponsor this project

Used by

Contributors

Languages