datastar-py


Namedatastar-py JSON
Version 0.4.1 PyPI version JSON
download
home_pageNone
SummaryHelper functions and classes for the Datastar library (https://data-star.dev/)
upload_time2024-12-28 16:46:16
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/40/58/6a1c78ec024e592c5f22c62bd4d0301f94f201ebdfd2d96035a1d06b1e75/datastar_py-0.4.1.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.1",
    "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": "c8ff1615ed29316fbf2d83923158372f7129fd5641d3fb4fe8fbc6fb78650da6",
                "md5": "0155aa3a87ff305700f67a4503e04307",
                "sha256": "86b16000f3971d823a1cb9501c396f8d03b7425a2406f42e3e01609d11914fc2"
            },
            "downloads": -1,
            "filename": "datastar_py-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0155aa3a87ff305700f67a4503e04307",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5410,
            "upload_time": "2024-12-28T16:46:14",
            "upload_time_iso_8601": "2024-12-28T16:46:14.417067Z",
            "url": "https://files.pythonhosted.org/packages/c8/ff/1615ed29316fbf2d83923158372f7129fd5641d3fb4fe8fbc6fb78650da6/datastar_py-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "40586a1c78ec024e592c5f22c62bd4d0301f94f201ebdfd2d96035a1d06b1e75",
                "md5": "ee915fd938c69ee8e30cce71ee064e2c",
                "sha256": "094aed4c51b9da82cca126acb1c6493f3593a8ff56b8be79d321a80590938d0e"
            },
            "downloads": -1,
            "filename": "datastar_py-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ee915fd938c69ee8e30cce71ee064e2c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 69645,
            "upload_time": "2024-12-28T16:46:16",
            "upload_time_iso_8601": "2024-12-28T16:46:16.371871Z",
            "url": "https://files.pythonhosted.org/packages/40/58/6a1c78ec024e592c5f22c62bd4d0301f94f201ebdfd2d96035a1d06b1e75/datastar_py-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-28 16:46:16",
    "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: 0.42596s