Skip to main content

Python & JS micro framework for realtime web UI applications

Project description

Sundash

Python & JS micro framework for realtime web UI applications

  • ASGI-based -- minimal 3rd party dependencies and clean core part
  • Flexible and extensible -- easy to customize, add 3rd party integrations
  • Realtime -- operating through websockets bus, client & backend in app
  • Crafted with ❤️

Link to project on PyPi: https://pypi.org/project/sundash/

Installation

    pip install sundash

Examples

    python -m examples <num | name>

To run Hello World example:

    python -m examples hello  # passing 01 also works

Available examples:

  • 01 hello - show plain HTML string
  • 02 buttons - counter with clickable buttons
  • 03 clock - realtime clock (scheduler events)
  • 04 menu - simple page routing
  • 05 search - handling signle form input
  • 06 tables - static tables

Client interaction example:

from dataclasses import dataclass

from sundash import App
from sundash import Component
from sundash import on
from sundash.app import ButtonClick

app = App()


class Counter(Component):
    html = '''
        <button id="minus">-</button>
        <b>{{ count }}</b>
        <button id="plus">+</button>
    '''

    @dataclass
    class Vars:
        count: int = 0

    @on(ButtonClick)
    async def on_click(self, event: ButtonClick):
        if 'plus' == event.button_id:
            self.vars.count += 1

        elif 'minus' == event.button_id:
            self.vars.count -= 1

        await self.update_var('count')


app.run_sync(['<h1>🧮 Counter</h1>', Counter])

Server Interaction Example:

import dataclasses as dc
import datetime as dt

from sundash import Component
from sundash import on
from sundash.scheduler import EverySecond
from sundash.scheduler import SchedulerApp

app = SchedulerApp()


now = lambda: dt.datetime.now().strftime('%H:%M:%S')


class Clock(Component):
    html = '<p><b>Time:</b> {{ time }}<p/>'

    @dc.dataclass
    class Vars:
        time: str = dc.field(default_factory=now)

    @on(EverySecond)
    async def update(self, _):
        self.vars.time = now()
        await self.update_var('time')


app.run_sync(['<h1>🕰️ Clock</h1>', Clock])

В чем идея?

Хочу пробрасывать real-time интерфейс к JS либам, чтобы была возможность написать любую веб-морду для любых системных инструментов.

Примеры использования: любые админки, торговые терминалы, дашборды мониторинга, тулзы для аналитики. Все кастомное и интерактивное, что хочется нарисовать, но ты бэкендер и хочешь писать преимущественно на Python с минимальным использованием JavaScript-а, без тяжеловесного инструментария фронтендеров (React и пр).

Development

  • Required: python 3.12, poetry, virtualenv
  • Install Python dependencies: poetry install --with=dev
  • Run local linters: poe q
  • Publish package: poetry publish --build

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

sundash-0.0.7.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

sundash-0.0.7-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file sundash-0.0.7.tar.gz.

File metadata

  • Download URL: sundash-0.0.7.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.8.4-100.fc38.x86_64

File hashes

Hashes for sundash-0.0.7.tar.gz
Algorithm Hash digest
SHA256 20805fc8fd571916eb7767b8b14af3fa0be2fda5309aa5d568b29492022ff94d
MD5 1a08dc3ec91d634890a99448af098d97
BLAKE2b-256 0076f09b038901eb5a00bf802d1793c15de5d4fe1a76dcb92f0afd92218ffda2

See more details on using hashes here.

File details

Details for the file sundash-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: sundash-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.8.4-100.fc38.x86_64

File hashes

Hashes for sundash-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 58417cbc772897e6b064b2a54fdf13f1c995a5a7df85c15e0248faa96b1bb65e
MD5 418a583882f71dfb184d9a43135f44e4
BLAKE2b-256 b91bdd2346810cd0eb9b9520b317feba5d634943ffe477ee653f32dc42fdac02

See more details on using hashes here.

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