datastar-py


Namedatastar-py JSON
Version 0.4.2 PyPI version JSON
download
home_pageNone
SummaryHelper functions and classes for the Datastar library (https://data-star.dev/)
upload_time2025-01-02 22:09:39
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords datastar django fastapi flask html quart sanic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Datastar-py

The `datastar_py` package provides backend helpers for the [Datastar](https://data-star.dev) JS library.

Datastar requires all backend responses to use SSE. This allows the backend to
send any number of responses, from zero to inifinity.

`Datastar-py` helps with the formatting of these responses, while also
providing helper functions for the different supported responses.

To use `datastar-py`, import the SSE generator in your app and then use
it in your route handler:

```python
from datastar_py import ServerSentEventGenerator as SSE

# ... various app setup. The example below is for the Quart framework

@app.route("/updates")
async def updates():
    async def time_updates():
        while True:
            yield SSE.merge_fragments(
                [f"""<span id="currentTime">{datetime.now().isoformat()}"""]
            )
            await asyncio.sleep(1)
            yield SSE.merge_signals({"currentTime": f"{datetime.now().isoformat()}"})
            await asyncio.sleep(1)

    response = await make_response(time_updates(), SSE_HEADERS)
    response.timeout = None
    return response
```

There are also a number of custom responses/helpers for various frameworks. Current ly the following frameworks are supported:

* [Sanic](https://sanic.dev/en/)
* [Django](https://www.djangoproject.com/)
* [Quart](https://quart.palletsprojects.com/en/stable/)
* [FastAPI](https://fastapi.tiangolo.com/)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "datastar-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "datastar, django, fastapi, flask, html, quart, sanic",
    "author": null,
    "author_email": "Felix Ingram <f.ingram@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/73/5d/ab173d33a48c651759dc4042b604b34b7b20cf93d43d32eaec3b76cb4853/datastar_py-0.4.2.tar.gz",
    "platform": null,
    "description": "# Datastar-py\n\nThe `datastar_py` package provides backend helpers for the [Datastar](https://data-star.dev) JS library.\n\nDatastar requires all backend responses to use SSE. This allows the backend to\nsend any number of responses, from zero to inifinity.\n\n`Datastar-py` helps with the formatting of these responses, while also\nproviding helper functions for the different supported responses.\n\nTo use `datastar-py`, import the SSE generator in your app and then use\nit in your route handler:\n\n```python\nfrom datastar_py import ServerSentEventGenerator as SSE\n\n# ... various app setup. The example below is for the Quart framework\n\n@app.route(\"/updates\")\nasync def updates():\n    async def time_updates():\n        while True:\n            yield SSE.merge_fragments(\n                [f\"\"\"<span id=\"currentTime\">{datetime.now().isoformat()}\"\"\"]\n            )\n            await asyncio.sleep(1)\n            yield SSE.merge_signals({\"currentTime\": f\"{datetime.now().isoformat()}\"})\n            await asyncio.sleep(1)\n\n    response = await make_response(time_updates(), SSE_HEADERS)\n    response.timeout = None\n    return response\n```\n\nThere are also a number of custom responses/helpers for various frameworks. Current ly the following frameworks are supported:\n\n* [Sanic](https://sanic.dev/en/)\n* [Django](https://www.djangoproject.com/)\n* [Quart](https://quart.palletsprojects.com/en/stable/)\n* [FastAPI](https://fastapi.tiangolo.com/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Helper functions and classes for the Datastar library (https://data-star.dev/)",
    "version": "0.4.2",
    "project_urls": {
        "Documentation": "https://github.com/starfederation/datastar/blob/develop/sdk/python/README.md",
        "GitHub": "https://github.com/starfederation/datastar"
    },
    "split_keywords": [
        "datastar",
        " django",
        " fastapi",
        " flask",
        " html",
        " quart",
        " sanic"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5ef96deec90c5cb16f405636c04c7a88662d020e28cd3c5c6ab8492763b8149c",
                "md5": "79718b7f095ba518fb64cef532587772",
                "sha256": "3d81a65c79e1aaba078b8dcd7497ab5337977a1151c5f18bb232c46188a2a87e"
            },
            "downloads": -1,
            "filename": "datastar_py-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79718b7f095ba518fb64cef532587772",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5423,
            "upload_time": "2025-01-02T22:09:37",
            "upload_time_iso_8601": "2025-01-02T22:09:37.290524Z",
            "url": "https://files.pythonhosted.org/packages/5e/f9/6deec90c5cb16f405636c04c7a88662d020e28cd3c5c6ab8492763b8149c/datastar_py-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "735dab173d33a48c651759dc4042b604b34b7b20cf93d43d32eaec3b76cb4853",
                "md5": "7d355a12f7161d175ee512aaf3da2659",
                "sha256": "d0a37d6d5189070015c4c5370b2ecf498580ba0315fbd1df8793b99a4b0f715e"
            },
            "downloads": -1,
            "filename": "datastar_py-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7d355a12f7161d175ee512aaf3da2659",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 66075,
            "upload_time": "2025-01-02T22:09:39",
            "upload_time_iso_8601": "2025-01-02T22:09:39.579551Z",
            "url": "https://files.pythonhosted.org/packages/73/5d/ab173d33a48c651759dc4042b604b34b7b20cf93d43d32eaec3b76cb4853/datastar_py-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-02 22:09:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "starfederation",
    "github_project": "datastar",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "datastar-py"
}
        
Elapsed time: 3.38015s