Metadata-Version: 2.1
Name: dazzler
Version: 0.8.0
Summary: Async Web Framework
Home-page: https://github.com/T4rk1n/dazzler
Author: Philippe Duval
Author-email: t4rk@outlook.com
License: MIT
Keywords: async,web,react,asyncio,aiohttp
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Session
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: precept (==0.6.5)
Requires-Dist: aiohttp (==3.7.4.post0)
Requires-Dist: appdirs (==1.4.4)
Requires-Dist: stringcase (==1.2.0)
Requires-Dist: itsdangerous (==2.0.1)
Provides-Extra: electron
Requires-Dist: PyInstaller (==4.5.1) ; extra == 'electron'
Provides-Extra: redis
Requires-Dist: aioredis (==1.3.1) ; extra == 'redis'

# Dazzler

[![Build](https://img.shields.io/circleci/build/github/T4rk1n/dazzler/master)](https://circleci.com/gh/T4rk1n/dazzler)
[![Documentation Status](https://readthedocs.org/projects/dazzler/badge/?version=latest)](https://dazzler.readthedocs.io/en/latest/?badge=latest)
[![Version](https://img.shields.io/pypi/v/dazzler)](https://pypi.org/project/dazzler/)
[![License](https://img.shields.io/pypi/l/dazzler)](LICENSE)

Dazzler is a Python async UI/Web framework built with [aiohttp](https://github.com/aio-libs/aiohttp) and react.
Create dazzling fast pages with a layout of Python components and bindings to update from the backend.

## Install

Install with pip: `$ pip install dazzler`

## Features

- Fast WebSocket based communication, deliver updates in realtime to thousands of connected clients at once.
- Lightweight bundles for fast initial page load.
- Support for third party integrations via middlewares.
- Session & authentication systems.
- No HTML/CSS/JS knowledge required, write everything with Python.
- Multi-page based.
- Hot reload.
- Tons of components.
- Tie & Transform API to perform updates on the client side.
- Build desktop applications with Electron.

## Basic example

Create a page with a layout and assign bindings to save & load a visitor name 
with the session system. The button to save the visitor name is disabled if
no input value via tie & transform.

```python
from dazzler import Dazzler
from dazzler.system import Page, BindingContext, transforms as t
from dazzler.components import core

app = Dazzler(__name__)
page = Page(
    __name__,
    core.Container([
        core.Html('H2', 'My dazzler page'),
        core.Container('Please enter a name', identity='visitor-name'),
        core.Input(value='', identity='input'),
        core.Button('Save name', identity='save-btn', disabled=True),
    ], identity='layout', id='layout'),
    title='My Page',
    url='/'
)

# UI updates via tie & transforms
page.tie('value@input', 'disabled@save-btn').transform(
    t.Length().t(t.Lesser(1))
)


# Bindings executes on the server via websockets.
@page.bind('clicks@save-btn')
async def on_click(context: BindingContext):
    # Save the visitor name via session system
    name = await context.get_aspect('input', 'value')
    await context.session.set('visitor', name)
    await context.set_aspect(
        'visitor-name', children=f'Saved {name}'
    )


# Aspects defined on the layout trigger on initial render and
# allows to insert initial data.
@page.bind('id@layout')
async def on_layout(context: BindingContext):
    visitor = await context.session.get('visitor')
    if visitor:
        await context.set_aspect(
            'visitor-name', children=f'Welcome back {visitor}!'
        )


app.add_page(page)

if __name__ == '__main__':
    app.start()
```

## Documentation

Full documentation hosted on [readthedocs](https://dazzler.readthedocs.io/en/latest/usage.html).

Get help for the command line tools: `$ dazzler --help`


