kkinder / puepy

Python+Webassembly Frontend Framework via PyScript
https://puepy.dev
Apache License 2.0
218 stars 9 forks source link
framework frontend frontend-framework pyscript python reactive webassembly

PuePy - PyScript Frontend Framework

➑️ Project Website πŸ“ Project Documentation

PuePy is a lightweight web framework that uses WebAssembly via PyScript to put Python right in your browser with all the modern conveniences of a web framework, but none of the headaches of Webpack, NPM or even JavaScript.

πŸ’ Try a demo app

See ExpenseLemur.com and the Expense Lemur Github Repo for a demonstration of what PuePy is capable of.

πŸ§‘β€πŸ’» See some code

from puepy import Page, Application, t

app = Application()

@app.page()
class Hello(Page):
    def initial(self):
        return dict(name="")

    def populate(self):
        with t.div(classes=["container", "mx-auto", "p-4"]):
            t.h1("Welcome to PyScript", classes=["text-xl", "pb-4"])
            if self.state["name"]:
                t.p(f"Hello there, {self.state['name']}")
            else:
                t.p("Why don't you tell me your name?")
            t.input(placeholder="Enter your name", bind="name")
            t.button("Continue", classes="btn btn-lg", on_click=self.on_button_click)

    def on_button_click(self, event):
        print("Button clicked")  # This logs to console

app.mount("#app")

Learn

License

PuePy is licensed under the Apache 2 license, for your coding convenience.