# Rizzler
[![Package vesion](https://img.shields.io/pypi/v/rizzler)](https://pypi.org/project/rizzler)
[![Format](https://img.shields.io/pypi/format/rizzler)](https://pypi.org/project/rizzler)
[![Python version](https://img.shields.io/pypi/pyversions/rizzler)](https://pypi.org/project/rizzler)
[![License](https://img.shields.io/pypi/l/rizzler)](https://pypi.org/project/rizzler)
[![Code size](https://img.shields.io/github/languages/code-size/aekasitt/rizzler)](.)
[![Top](https://img.shields.io/github/languages/top/aekasitt/rizzler)](.)
[![Languages](https://img.shields.io/github/languages/count/aekasitt/rizzler)](.)
[![Repository size](https://img.shields.io/github/repo-size/aekasitt/rizzler)](.)
[![Last commit](https://img.shields.io/github/last-commit/aekasitt/rizzler/master)](.)
[![Rizzler Banner](./static/rizzler-banner.svg)](https://github.com/aekasitt/rizzler/blob/master/static/rizzler-banner.svg)
## Installation
Install using pip
```sh
$ pip install rizzler
> ...
```
## Usage
Integrate with `lifespan` protocol.
```python
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.requests impor Request
from fastapi.responses import HTMLResponse
from rizzler import RizzleTemplates, Rizzler
from typing import AsyncIterator, List, Tuple
@Rizzler.load_config
def rizzler_settings() -> List[Tuple[str, str]]:
return [
("command", "pnpm"),
("framework", "vue")
]
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncIterator[None, None]:
await Rizzler.serve()
yield
Rizzler.shutdown()
app: FastAPI = FastAPI(lifespan=lifespan)
templates: RizzleTemplates = RizzleTemplates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def index(request: Request) -> HTMLResponse:
return templates.TemplateResponse("index.html", {"request": request})
```
### Templating
`RizzleTemplates` is an extension on top of `Jinja2Templates` class found under [starlette](starlette.io)
However, has two overriding methods that must be placed inside the template HTML-file as such:
```html
<!DOCTYPE html>
<html>
<head><!-- ... --></head>
<body>
{{ vite_hmr_client() }}
{{ vite_asset('pages/main.js') }}
</body>
</html>
```
## Build
This section talks about how to use `Jinja2Templates` in place of `RizzleTemplates` for built assets
from the `vite build` command inside `package.json`.
To be determined.
## Contributions
To be determined.
## Acknowledgements
* [fastapi-vite](https://github.com/cofin/fastapi-vite)
* [django-vite](https://github.com/MrBin99/django-vite)
## License
This project is licensed under the terms of the MIT license.
Raw data
{
"_id": null,
"home_page": "https://github.com/aekasitt/rizzler",
"name": "rizzler",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "asgi, blacksheep, fastapi, hmr, javascript, litestar, node, npm, pnpm, quart, sanic, starlette, uvicorn, vite",
"author": "Sitt Guruvanich",
"author_email": "aekazitt+github@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8d/78/801e2a87bd1dea8318280bb2408c846cd8e6931ccfc6b224a6c69efb5133/rizzler-0.1.5.tar.gz",
"platform": null,
"description": "# Rizzler\n\n[![Package vesion](https://img.shields.io/pypi/v/rizzler)](https://pypi.org/project/rizzler)\n[![Format](https://img.shields.io/pypi/format/rizzler)](https://pypi.org/project/rizzler)\n[![Python version](https://img.shields.io/pypi/pyversions/rizzler)](https://pypi.org/project/rizzler)\n[![License](https://img.shields.io/pypi/l/rizzler)](https://pypi.org/project/rizzler)\n[![Code size](https://img.shields.io/github/languages/code-size/aekasitt/rizzler)](.)\n[![Top](https://img.shields.io/github/languages/top/aekasitt/rizzler)](.)\n[![Languages](https://img.shields.io/github/languages/count/aekasitt/rizzler)](.)\n[![Repository size](https://img.shields.io/github/repo-size/aekasitt/rizzler)](.)\n[![Last commit](https://img.shields.io/github/last-commit/aekasitt/rizzler/master)](.)\n[![Rizzler Banner](./static/rizzler-banner.svg)](https://github.com/aekasitt/rizzler/blob/master/static/rizzler-banner.svg)\n\n## Installation\n\nInstall using pip\n\n```sh\n$ pip install rizzler\n> ...\n```\n\n## Usage\n\nIntegrate with `lifespan` protocol.\n\n```python\nfrom contextlib import asynccontextmanager\nfrom fastapi import FastAPI\nfrom fastapi.requests impor Request\nfrom fastapi.responses import HTMLResponse\nfrom rizzler import RizzleTemplates, Rizzler\nfrom typing import AsyncIterator, List, Tuple\n\n@Rizzler.load_config\ndef rizzler_settings() -> List[Tuple[str, str]]:\n return [\n (\"command\", \"pnpm\"),\n (\"framework\", \"vue\")\n ]\n\n@asynccontextmanager\nasync def lifespan(_: FastAPI) -> AsyncIterator[None, None]:\n await Rizzler.serve()\n yield\n Rizzler.shutdown()\n\napp: FastAPI = FastAPI(lifespan=lifespan)\ntemplates: RizzleTemplates = RizzleTemplates(directory=\"templates\")\n\n@app.get(\"/\", response_class=HTMLResponse)\nasync def index(request: Request) -> HTMLResponse:\n return templates.TemplateResponse(\"index.html\", {\"request\": request})\n```\n\n### Templating\n\n`RizzleTemplates` is an extension on top of `Jinja2Templates` class found under [starlette](starlette.io)\nHowever, has two overriding methods that must be placed inside the template HTML-file as such:\n\n```html\n<!DOCTYPE html>\n<html>\n <head><!-- ... --></head>\n <body>\n {{ vite_hmr_client() }}\n {{ vite_asset('pages/main.js') }}\n </body>\n</html>\n```\n\n## Build\n\nThis section talks about how to use `Jinja2Templates` in place of `RizzleTemplates` for built assets\nfrom the `vite build` command inside `package.json`.\n\nTo be determined.\n\n## Contributions\n\nTo be determined.\n\n## Acknowledgements\n\n* [fastapi-vite](https://github.com/cofin/fastapi-vite)\n* [django-vite](https://github.com/MrBin99/django-vite)\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Rizzler creates a parallel front-end dev-server using ViteJS for ASGI Frameworks",
"version": "0.1.5",
"project_urls": {
"Homepage": "https://github.com/aekasitt/rizzler",
"Repository": "https://github.com/aekasitt/rizzler"
},
"split_keywords": [
"asgi",
" blacksheep",
" fastapi",
" hmr",
" javascript",
" litestar",
" node",
" npm",
" pnpm",
" quart",
" sanic",
" starlette",
" uvicorn",
" vite"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "035d82d6827fd158232a8277b203f7d137b650a3608e589cf004c7b6ac3a272b",
"md5": "abcb1cc790a46c2ef630feb8f6d82983",
"sha256": "a857b3c1cac5e2c326d7758c4a74c3e7f0302ddb5c1fa1a313105e0ae43e447d"
},
"downloads": -1,
"filename": "rizzler-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "abcb1cc790a46c2ef630feb8f6d82983",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 14351,
"upload_time": "2024-06-11T08:51:23",
"upload_time_iso_8601": "2024-06-11T08:51:23.168405Z",
"url": "https://files.pythonhosted.org/packages/03/5d/82d6827fd158232a8277b203f7d137b650a3608e589cf004c7b6ac3a272b/rizzler-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8d78801e2a87bd1dea8318280bb2408c846cd8e6931ccfc6b224a6c69efb5133",
"md5": "851ff98ad9937991a2b386fe95de9f54",
"sha256": "4a179c372efffb738cc2d82a29eb97c00ee1f18c6b1f17d8dbe001f3a4570419"
},
"downloads": -1,
"filename": "rizzler-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "851ff98ad9937991a2b386fe95de9f54",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 9065,
"upload_time": "2024-06-11T08:51:24",
"upload_time_iso_8601": "2024-06-11T08:51:24.512242Z",
"url": "https://files.pythonhosted.org/packages/8d/78/801e2a87bd1dea8318280bb2408c846cd8e6931ccfc6b224a6c69efb5133/rizzler-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-11 08:51:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aekasitt",
"github_project": "rizzler",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "rizzler"
}