pyview-web


Namepyview-web JSON
Version 0.0.6a0 PyPI version JSON
download
home_pagehttps://pyview.rocks
SummaryLiveView in Python
upload_time2023-05-17 01:51:05
maintainer
docs_urlNone
authorLarry Ogrodnek
requires_python>=3.9.16,<4.0.0
licenseMIT
keywords web api liveview
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img src="https://pyview.rocks/images/pyview_logo_512.png" width="128px" align="right" />

# PyView

> A Python implementation of Phoenix LiveView

PyView enables dynamic, real-time web apps, using server-rendered HTML.

**Source Code**: <a href="https://github.com/ogrodnek/pyview" target="_blank">https://github.com/ogrodnek/pyview</a>

# Installation

`pip install pyview-web`

# Live Examples

[https://examples.pyview.rocks/](https://examples.pyview.rocks/)

## Simple Counter

[See it live!](https://examples.pyview.rocks/count)

count.py:

```python
from pyview import LiveView, LiveViewSocket
from typing import TypedDict


class CountContext(TypedDict):
    count: int


class CountLiveView(LiveView[CountContext]):
    async def mount(self, socket: LiveViewSocket[CountContext]):
        socket.context = {"count": 0}

    async def handle_event(self, event, payload, socket: LiveViewSocket[CountContext]):
        if event == "decrement":
            socket.context["count"] -= 1

        if event == "increment":
            socket.context["count"] += 1

    async def handle_params(self, url, params, socket: LiveViewSocket[CountContext]):
        if "c" in params:
            socket.context["count"] = int(params["c"][0])
```

count.html:

```html
<div>
  <h1>Count is {{count}}</h1>
  <button phx-click="decrement">-</button>
  <button phx-click="increment">+</button>
</div>
```

# Acknowledgements

- Obviously this project wouldn't exist without [Phoenix LiveView](https://github.com/phoenixframework/phoenix_live_view), which is a wonderful paradigm and implementation. Besides using their ideas, we also directly use the LiveView JavaScript code.
- Thanks to [Donnie Flood](https://github.com/floodfx) for the encouragement, inspiration, help, and even pull requests to get this project started! Check out [LiveViewJS](https://github.com/floodfx/liveviewjs) for a TypeScript implementation of LiveView (that's much more mature than this one!)

- Thanks to [Darren Mulholland](https://github.com/dmulholl) for both his [Let's Build a Template Language](https://www.dmulholl.com/lets-build/a-template-language.html) tutorial, as well as his [ibis template engine](https://github.com/dmulholl/ibis), which he very generously released into the public domain, and forms the basis of templating in PyView.

## Additional Thanks

- We're using the [pubsub implementation from flet](https://github.com/flet-dev/flet)
- PyView is built on top of [FastAPI](https://fastapi.tiangolo.com), and of course, [Starlette](https://www.starlette.io/).

# Status

PyView is in the very early stages of active development. Please check it out and give feedback! Note that the API is likely to change, and there are many features that are not yet implemented.

# Running the included Examples

## Setup

```
poetry install
```

## Running

```
poetry run uvicorn examples.app:app --reload
```

Then go to http://localhost:8000/

### Poetry Install

```
brew install pipx
pipx install poetry
pipx ensurepath
```

(see https://python-poetry.org/docs/#installation for more details)

# License

PyView is licensed under the [MIT License](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://pyview.rocks",
    "name": "pyview-web",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9.16,<4.0.0",
    "maintainer_email": "",
    "keywords": "web,api,LiveView",
    "author": "Larry Ogrodnek",
    "author_email": "ogrodnek@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/79/c8/ec93e47227d60d6b9c46026c3459c8b4082e7b78eda8a18025a9d09530c0/pyview_web-0.0.6a0.tar.gz",
    "platform": null,
    "description": "<img src=\"https://pyview.rocks/images/pyview_logo_512.png\" width=\"128px\" align=\"right\" />\n\n# PyView\n\n> A Python implementation of Phoenix LiveView\n\nPyView enables dynamic, real-time web apps, using server-rendered HTML.\n\n**Source Code**: <a href=\"https://github.com/ogrodnek/pyview\" target=\"_blank\">https://github.com/ogrodnek/pyview</a>\n\n# Installation\n\n`pip install pyview-web`\n\n# Live Examples\n\n[https://examples.pyview.rocks/](https://examples.pyview.rocks/)\n\n## Simple Counter\n\n[See it live!](https://examples.pyview.rocks/count)\n\ncount.py:\n\n```python\nfrom pyview import LiveView, LiveViewSocket\nfrom typing import TypedDict\n\n\nclass CountContext(TypedDict):\n    count: int\n\n\nclass CountLiveView(LiveView[CountContext]):\n    async def mount(self, socket: LiveViewSocket[CountContext]):\n        socket.context = {\"count\": 0}\n\n    async def handle_event(self, event, payload, socket: LiveViewSocket[CountContext]):\n        if event == \"decrement\":\n            socket.context[\"count\"] -= 1\n\n        if event == \"increment\":\n            socket.context[\"count\"] += 1\n\n    async def handle_params(self, url, params, socket: LiveViewSocket[CountContext]):\n        if \"c\" in params:\n            socket.context[\"count\"] = int(params[\"c\"][0])\n```\n\ncount.html:\n\n```html\n<div>\n  <h1>Count is {{count}}</h1>\n  <button phx-click=\"decrement\">-</button>\n  <button phx-click=\"increment\">+</button>\n</div>\n```\n\n# Acknowledgements\n\n- Obviously this project wouldn't exist without [Phoenix LiveView](https://github.com/phoenixframework/phoenix_live_view), which is a wonderful paradigm and implementation. Besides using their ideas, we also directly use the LiveView JavaScript code.\n- Thanks to [Donnie Flood](https://github.com/floodfx) for the encouragement, inspiration, help, and even pull requests to get this project started! Check out [LiveViewJS](https://github.com/floodfx/liveviewjs) for a TypeScript implementation of LiveView (that's much more mature than this one!)\n\n- Thanks to [Darren Mulholland](https://github.com/dmulholl) for both his [Let's Build a Template Language](https://www.dmulholl.com/lets-build/a-template-language.html) tutorial, as well as his [ibis template engine](https://github.com/dmulholl/ibis), which he very generously released into the public domain, and forms the basis of templating in PyView.\n\n## Additional Thanks\n\n- We're using the [pubsub implementation from flet](https://github.com/flet-dev/flet)\n- PyView is built on top of [FastAPI](https://fastapi.tiangolo.com), and of course, [Starlette](https://www.starlette.io/).\n\n# Status\n\nPyView is in the very early stages of active development. Please check it out and give feedback! Note that the API is likely to change, and there are many features that are not yet implemented.\n\n# Running the included Examples\n\n## Setup\n\n```\npoetry install\n```\n\n## Running\n\n```\npoetry run uvicorn examples.app:app --reload\n```\n\nThen go to http://localhost:8000/\n\n### Poetry Install\n\n```\nbrew install pipx\npipx install poetry\npipx ensurepath\n```\n\n(see https://python-poetry.org/docs/#installation for more details)\n\n# License\n\nPyView is licensed under the [MIT License](LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "LiveView in Python",
    "version": "0.0.6a0",
    "project_urls": {
        "Homepage": "https://pyview.rocks",
        "Repository": "https://github.com/ogrodnek/pyview"
    },
    "split_keywords": [
        "web",
        "api",
        "liveview"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25d5c78389cbb3c42d3b45d36ecaaab632dfa18191c7f30a26be0b83c05d5d02",
                "md5": "45e9fb1e0f65a69caa6e36d2d5f4aacf",
                "sha256": "befe8fc5718c32fbf240a43179a1a0ae08990faba147f6cad5b2747d05af45de"
            },
            "downloads": -1,
            "filename": "pyview_web-0.0.6a0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "45e9fb1e0f65a69caa6e36d2d5f4aacf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.16,<4.0.0",
            "size": 77502,
            "upload_time": "2023-05-17T01:51:03",
            "upload_time_iso_8601": "2023-05-17T01:51:03.959526Z",
            "url": "https://files.pythonhosted.org/packages/25/d5/c78389cbb3c42d3b45d36ecaaab632dfa18191c7f30a26be0b83c05d5d02/pyview_web-0.0.6a0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "79c8ec93e47227d60d6b9c46026c3459c8b4082e7b78eda8a18025a9d09530c0",
                "md5": "43eaa79c7a7d9220a4532e143553bfeb",
                "sha256": "5d0b2f54bfd2bf53d057557b576ffe1dedf258c4e638821709e0b4c3ea385620"
            },
            "downloads": -1,
            "filename": "pyview_web-0.0.6a0.tar.gz",
            "has_sig": false,
            "md5_digest": "43eaa79c7a7d9220a4532e143553bfeb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.16,<4.0.0",
            "size": 70259,
            "upload_time": "2023-05-17T01:51:05",
            "upload_time_iso_8601": "2023-05-17T01:51:05.794733Z",
            "url": "https://files.pythonhosted.org/packages/79/c8/ec93e47227d60d6b9c46026c3459c8b4082e7b78eda8a18025a9d09530c0/pyview_web-0.0.6a0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-17 01:51:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ogrodnek",
    "github_project": "pyview",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyview-web"
}
        
Elapsed time: 0.07545s