Skip to main content

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 path

    from 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)

Uploaded Source

Built Distribution

fastapi_view-0.0.1-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page