Skip to main content

Adds s-expression HTML tags (FTags) to FastAPI views. Inspired by FastHTML's use of fastcore's FT components.

Project description

FastAPI Tags

Adds s-expression HTML tags (FTags) to FastAPI views. Inspired by FastHTML's use of fastcore's FT components.

Test Package version Supported Python versions

Installation:

uv:

uv add fastapi-tags

pip:

pip install fastapi-tags
uv pip install fastapi-tags

Usage:

from fastapi import FastAPI
import fastapi_tags as ft

app = FastAPI()

@app.get("/", response_class=ft.FTResponse)
async def index():
    return ft.Html(ft.H1("Hello, world!", style="color: blue;"))

If you want to do snippets, just skip the ft.Html tag:

@app.get("/time", response_class=ft.FTResponse)
async def time():
    return ft.P("Time to do code!")

Subclassing

class AwesomeP(ft.P):
    def render(self) -> str:
        return f"<p{self.attrs}>AWESOME {self.children}!</p>"
<p>AWESOME library!</p>

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_tags-0.2.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_tags-0.2.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_tags-0.2.1.tar.gz.

File metadata

  • Download URL: fastapi_tags-0.2.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.3

File hashes

Hashes for fastapi_tags-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ba5e56b21144869396a1052ac146b03812aae60f0f1ed593431ee5becf65ad44
MD5 a2726f2e14e046f767ee452c15be7dac
BLAKE2b-256 0e32e88a7bd2448184956f04d449958e7c068583c1c8bb2514a372c1f8e132ed

See more details on using hashes here.

File details

Details for the file fastapi_tags-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_tags-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72b962cfbc537dc6154a86e85a0813c51315730deb998ef7f2fba2eab8686add
MD5 2ee1c49719c0c0f3f43279df601f5f02
BLAKE2b-256 adfbe8119a6cd340601580cf21beabc94c55c68ffd707e9a35818a3734e48a26

See more details on using hashes here.

Supported by

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