# fastapi-view
A jinja2 view template helping function for FastAPI.
Features:
- Simply setting and use function to return Jinja2Templates
## Installation
```shell
pip install fastapi-view
```
# Usage
- Configuring `fastapi-view` jinja2 templates directory path
```python
from fastapi_view import view
# setting root view templates directory path
view.views_directory = "/your/jinja2/template/directory/path"
```
- Use view()
```python
from fastapi import FastAPI
from fastapi.requests import Request
from fastapi_view.middleware import ViewRequestMiddleware
from fastapi_view import view
app = FastAPI()
app.add_middleware(ViewRequestMiddleware)
@app.get("/")
def index():
return view("index", {"foo": "bar"})
```
- Use inertia render
```python
from fastapi import FastAPI
from fastapi.requests import Request
from fastapi_view.middleware import ViewRequestMiddleware
from fastapi_view import inertia
app = FastAPI()
app.add_middleware(ViewRequestMiddleware)
@app.get("/inertia/page")
def inertia_index():
return inertia.render("Index", props={"foo": "bar"})
```
Raw data
{
"_id": null,
"home_page": "https://github.com/turisesonia/fastapi-view.git",
"name": "fastapi-view",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "Fastapi,template,view,jinja2",
"author": "Sam Yao",
"author_email": "turisesonia@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3d/05/58e11767e7c80e497bd83a1fb6905c51c195367769e3fa9cedc3e5aa042f/fastapi_view-0.2.0.tar.gz",
"platform": null,
"description": "# fastapi-view\n\nA jinja2 view template helping function for FastAPI.\n\nFeatures:\n\n- Simply setting and use function to return Jinja2Templates\n\n## Installation\n\n```shell\npip install fastapi-view\n```\n\n# Usage\n\n- Configuring `fastapi-view` jinja2 templates directory path\n\n ```python\n from fastapi_view import view\n\n # setting root view templates directory path\n view.views_directory = \"/your/jinja2/template/directory/path\"\n ```\n\n- Use view()\n\n ```python\n from fastapi import FastAPI\n from fastapi.requests import Request\n from fastapi_view.middleware import ViewRequestMiddleware\n from fastapi_view import view\n\n app = FastAPI()\n app.add_middleware(ViewRequestMiddleware)\n\n @app.get(\"/\")\n def index():\n return view(\"index\", {\"foo\": \"bar\"})\n\n ```\n\n- Use inertia render\n\n ```python\n from fastapi import FastAPI\n from fastapi.requests import Request\n from fastapi_view.middleware import ViewRequestMiddleware\n from fastapi_view import inertia\n\n app = FastAPI()\n app.add_middleware(ViewRequestMiddleware)\n\n @app.get(\"/inertia/page\")\n def inertia_index():\n return inertia.render(\"Index\", props={\"foo\": \"bar\"})\n\n ```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A jinja2 view template helping function for FastAPI.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/turisesonia/fastapi-view.git",
"Repository": "https://github.com/turisesonia/fastapi-view.git"
},
"split_keywords": [
"fastapi",
"template",
"view",
"jinja2"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8ab6fb2f44ac7293bd05366c3e7113052bbb139c9245114d260d71c3d966792b",
"md5": "fb5b4a7cf08bce62fd2ab1fbb9c467d4",
"sha256": "a64de74ba7927afd0a3150dd1c7b261d55b0b76f246c3d6d4abd2fdb33f53978"
},
"downloads": -1,
"filename": "fastapi_view-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fb5b4a7cf08bce62fd2ab1fbb9c467d4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 4961,
"upload_time": "2023-11-17T07:42:00",
"upload_time_iso_8601": "2023-11-17T07:42:00.795659Z",
"url": "https://files.pythonhosted.org/packages/8a/b6/fb2f44ac7293bd05366c3e7113052bbb139c9245114d260d71c3d966792b/fastapi_view-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3d0558e11767e7c80e497bd83a1fb6905c51c195367769e3fa9cedc3e5aa042f",
"md5": "4d00560c3cd4914c754cd21b9b6acd37",
"sha256": "0a22231ae907e4b6c7591dd95ece561d290b094d49be2bd10d95dbcbcd1537b5"
},
"downloads": -1,
"filename": "fastapi_view-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "4d00560c3cd4914c754cd21b9b6acd37",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 3852,
"upload_time": "2023-11-17T07:42:03",
"upload_time_iso_8601": "2023-11-17T07:42:03.330515Z",
"url": "https://files.pythonhosted.org/packages/3d/05/58e11767e7c80e497bd83a1fb6905c51c195367769e3fa9cedc3e5aa042f/fastapi_view-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-17 07:42:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "turisesonia",
"github_project": "fastapi-view",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "fastapi-view"
}