Skip to main content

Write responsive web apps in full python

Project description

doc/content/logo.svg pypi.org Travis branch pypi.org pypi.org codecov.io

Lona is a web application framework, designed to write responsive web apps in full Python.

Documentation: lona-web.org

Changelog: lona-web.org/changelog

Web is a solved problem in Python since ages, but traditionally Python handles only the server side. If you want to have client side interaction like click events or you want update content live, you have to write an additional Javascript application.

Lona handles the server side and the client side, and provides a simple, pythonic API to write self contained views.

from lona.html import HTML, Button, Div, H1
from lona import LonaApp, LonaView

app = LonaView(__file__)

@app.route('/')
class MyView(LonaView):
    def handle_request(self, request):
        message = Div('Button not clicked')
        button = Button('Click me!')

        html = HTML(
            H1('Click the button!'),
            message,
            button,
        )

        request.client.show(html)

        # this call blocks until the button was clicked
        input_event = request.client.await_click(button)

        if input_event.node == button:
            message.set_text('Button clicked')

        return html


app.run(port=8080)

More information: Getting Started

How does it work?

Lona comes with a Javascript based browser library that speaks a specialized protocol with the backend. This protocol specifies messages like “hey frontend, please show $HTML” and “hey backend, someone clicked on node XY”.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lona-1.1.tar.gz (640.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page