Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 7, 2026·2 min de lecture

FastHTML — Build AI Web Apps in Pure Python

Modern Python web framework that generates HTML from Python functions. No JavaScript, no templates. Perfect for building AI tool dashboards and agent UIs rapidly.

Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 66/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
FastHTML — Build AI Web Apps in Pure Python
Commande avec revue préalable
npx -y tokrepo@latest install 143825f7-ee67-49a1-a994-6908bb1df20f --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

TL;DR
FastHTML builds full web applications in pure Python using HTMX for interactivity, with no JavaScript required.
§01

What it is

FastHTML is a Python web framework that lets you build modern, interactive web applications entirely in Python. It uses HTMX for client-side interactivity, so you write Python functions that return HTML components without touching JavaScript. Server-side rendering is the default, making it naturally suited for AI-integrated applications where the backend does the heavy lifting.

FastHTML targets Python developers, data scientists, and AI engineers who want to build web UIs for their models and tools without learning a frontend framework.

§02

How it saves time or tokens

Traditional web development requires separate frontend and backend codebases, typically involving React or Vue plus a Python API. FastHTML eliminates the frontend build step entirely. You write Python functions decorated with routes, return HTML components, and HTMX handles dynamic updates. This cuts the technology stack in half and removes the need for API serialization between frontend and backend.

§03

How to use

  1. Install FastHTML:
pip install python-fasthtml
  1. Create a minimal app:
from fasthtml.common import *

app, rt = fast_app()

@rt('/')
def get():
    return Titled('Hello', P('Welcome to FastHTML'))

serve()
  1. Run your app:
python main.py
# Open http://localhost:5001
§04

Example

An AI chat interface built with FastHTML:

from fasthtml.common import *
import openai

app, rt = fast_app()
messages = []

@rt('/')
def get():
    chat_list = Ul(*[Li(m) for m in messages], id='chat')
    form = Form(
        Input(name='msg', placeholder='Ask anything...'),
        Button('Send'),
        hx_post='/chat', hx_target='#chat', hx_swap='innerHTML'
    )
    return Titled('AI Chat', chat_list, form)

@rt('/chat')
def post(msg: str):
    messages.append(f'You: {msg}')
    response = openai.chat.completions.create(
        model='gpt-4o-mini',
        messages=[{'role': 'user', 'content': msg}]
    )
    messages.append(f'AI: {response.choices[0].message.content}')
    return Ul(*[Li(m) for m in messages])

serve()
§05

Related on TokRepo

§06

Common pitfalls

  • FastHTML uses HTMX for interactivity; complex client-side state management (like drag-and-drop) still requires JavaScript
  • The framework is relatively new; community resources and third-party plugins are limited compared to Flask or Django
  • Server-side rendering means every interaction hits the server; for high-traffic applications, consider adding caching or rate limiting

Questions fréquentes

How is FastHTML different from Streamlit?+

Streamlit is designed for data dashboards with a widget-based API. FastHTML is a general-purpose web framework that gives you full control over HTML structure, routing, and styling. FastHTML produces standard web apps; Streamlit produces data apps with a specific look and feel.

Can I use CSS frameworks with FastHTML?+

Yes. FastHTML works with any CSS framework. You can include Tailwind CSS, Bootstrap, or custom stylesheets. The framework generates standard HTML, so any CSS applies normally.

Does FastHTML support WebSockets?+

Yes. FastHTML supports WebSocket connections for real-time features like streaming LLM responses. You define WebSocket handlers alongside regular HTTP routes in the same Python file.

Can I deploy FastHTML to production?+

Yes. FastHTML apps run on any Python hosting platform. Deploy with Uvicorn behind Nginx for production. Railway, Render, and Fly.io all support Python ASGI applications, which FastHTML uses under the hood.

Does FastHTML require JavaScript knowledge?+

No. The core value proposition is building interactive web apps without JavaScript. HTMX handles dynamic content updates through HTML attributes. You may need minimal JavaScript only for highly custom client-side behaviors.

Sources citées (3)
  • FastHTML GitHub— FastHTML builds web apps in pure Python with HTMX
  • HTMX Docs— HTMX provides interactivity through HTML attributes
  • FastHTML Docs— FastHTML documentation and tutorials
🙏

Source et remerciements

Created by Jeremy Howard / Answer.AI. Licensed under Apache 2.0.

AnswerDotAI/fasthtml — 8k+ stars

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires