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.2.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_view-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08fa79a0032a0af0fa856fb6e6127f5e9cdde15ba32152ab1ad47ebbdc85414d |
|
MD5 | 032e797e69617779095437ac3487cf1f |
|
BLAKE2b-256 | dcd0bb7e1d469d560e7b58e7e8bef5479e9fe4c1642d50fc29e932b73ed730e3 |