Skip to main content

auto_template

Auto-configures FastAPI's Jinja2Templates with canonical URL and static file cache-busting on import.

PyPI version Python versions License: MIT

What does this package do?

This package automatically assigns versions to static files and completes the canonical values.

Installation

  • Install via pip
    pip install auto_template
    
  • Install via uv
    uv add auto_template
    

Usage

  • app.py
    from fastapi import FastAPI
    from auto_template import setup_templates
    
    app = FastAPI()
    
    templates = setup_templates(directory="templates")
    
  • templates/base.html
    <head>
        <link rel="stylesheet" href="<path_to_css_file>v?={{ static_version('<path_to_css_file') }}">
        <link rel="canonical" href="{{ canonical_url }}">
    </head>
    

License

MIT

Release files for auto-template 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for auto-template 1.0.0
File Size Uploaded
auto_template-1.0.0.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for auto-template 1.0.0
File Interpreter ABI Platform
auto_template-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.2 kB

Release files / auto_template-1.0.0.tar.gz

Download URL auto_template-1.0.0.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
08b09b0508b482f30a08f9bcc3dc2bc5e74f0978ad5a125846ac2de187ecd7ac
BLAKE2b-256 checksum
How to use checksums
85a424721c45563c2c9e3d57df368838303c942c84724392b27dc82ce5039597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / auto_template-1.0.0-py3-none-any.whl

Download URL auto_template-1.0.0-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4df0f4b56f12da0994394be281d3bbb2b8878c145c544daccd27f96ea46461ae
BLAKE2b-256 checksum
How to use checksums
09ba52e1a771b046b668534383e2bad7a0ecaa6fa814b0c1f7922fc4aec94832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page