No project description provided
Project description
fastapi-view
A jinja2 view template helping function for FastAPI.
Features:
- Simply setting and use function to return Jinja2Templates
Installation
pip install fastapi-view
Usage
-
Configuring
fastapi-view
jinja2 templates directory pathfrom fastapi_view import view # setting root view templates directory path view.views_directory = "/your/jinja2/template/directory/path"
-
Use view()
from fastapi import FastAPI from fastapi.requests import Request from fastapi_view import view app = FastAPI() @app.get("/") def index(request: Request): return view("index", {"request": request, "foo": "bar"})
-
Use inertia render
from fastapi import FastAPI from fastapi.requests import Request from fastapi_view import inertia app = FastAPI() @app.get("/inertia/page") def inertia_index(request: Request): return inertia.render("Index", request=request, props={"foo": "bar"})
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastapi-view-0.0.1.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_view-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c480be2ae59aa20b194cb2caa13b801a7f38de8655a50d1393fc5fbdc3102084 |
|
MD5 | 71c496ac0d7ae5ccb93c07a481cf9d3e |
|
BLAKE2b-256 | 80c26aaf2d6dc7eea4260fef01cd4aabbe71a4dbbd8d7e22144b5104c5be0946 |