fastapi-view-0.1.0
توضیحات
A jinja2 view template helping function for FastAPI.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | fastapi-view-0.1.0 |
| نام | fastapi-view |
| نسخه کتابخانه | 0.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Sam Yao |
| ایمیل نویسنده | turisesonia@gmail.com |
| آدرس صفحه اصلی | https://github.com/turisesonia/fastapi-view.git |
| آدرس اینترنتی | https://pypi.org/project/fastapi-view/ |
| مجوز | MIT |
# 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()
from fastapi_view.middleware import ViewRequestMiddleware
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"})
```
نیازمندی
| مقدار | نام |
|---|---|
| >=0.70.0 | fastapi |
| >=5.0.0,<6.0.0 | ujson |
| >=3.0.0,<4.0.0 | Jinja2 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7,<4.0 | Python |
نحوه نصب
نصب پکیج whl fastapi-view-0.1.0:
pip install fastapi-view-0.1.0.whl
نصب پکیج tar.gz fastapi-view-0.1.0:
pip install fastapi-view-0.1.0.tar.gz