Modern web applications in pure Python

Built on solid web foundations, not the latest fads - with FastHTML you can get started on anything from simple dashboards to scalable web applications in minutes.

Learn more Video poster Watch intro 7min 30sec

Youtube icon

This home page is a FastHTML app.

Click the buttons below to see four small, live components in action.

card3d.py

            def card_3d_demo():
    """This is a standalone isolated Python component.
    Behavior and styling is scoped to the component."""
    def card_3d(text, background, amt, left_align):
        # JS and CSS can be defined inline or in a file
        scr = ScriptX('card3d.js', amt=amt)
        align='left' if left_align else 'right'
        sty = StyleX('card3d.css', background=f'url({background})', align=align)
        return Div(text, Div(), sty, scr)
    # Design credit: https://codepen.io/markmiro/pen/wbqMPa
    card = card_3d("Mouseover me", bgurl, amt=1.5, left_align=True)
    return Div(card, style=cardcss)

          
Mouseover me

GET STARTED IN MINUTES

The fastest way to create a real web application.

With FastHTML you create good-looking modern web applications in pure Python and deploy them in minutes.

Get started fast

A single Python file is all that's needed to create any app you can think of. Or bring in any Python or JS library you like.

Flexibility

FastHTML provides full access to HTTP, HTML, JS, and CSS, bringing the foundations of the web to you. There's no limits to what you can build.

Speed & scale

FastHTML applications are fast and scalable. They're also easy to deploy, since you can use any hosting service that supports Python.

TECH STACK

FastHTML scales up and scales down.

Read more about our design philosophy here , or click a button below:

Build on solid foundations

FastHTML stands on the shoulders of giants:

Use tools you already know

FastHTML embraces the familiar:

Deploy anywhere

FastHTML runs anywhere Python does, including 1-click deploy to:

SAMPLES

See FastHTML in action

FastHTML can be used for everything from collaborative games to multi-modal UI. We've selected small self-contained examples for you to learn from.

Discover all

FAQ

Questions? Answers.

Your top FastHTML questions clarified.

It's good for: general purpose web applications (i.e anything you'd build with React, Django, Next.js, etc); quick dashboards, prototypes, and in-company apps (e.g. like what you might use gradio/streamlit/etc for); Analytics/models/dashboards interactive reports; Custom blogs and content-heavy sites where you also want some interactive/dynamic content.

You can deploy a FastHTML app to any service or server that supports Python. We have guides and helpers for Railway.app, Vercel, Hugging Face Spaces, Replit, and PythonAnywhere. You can also use any VPS or server, or any on-premise machine with Python installed. All major operating systems are supported.

FastAPI is one of the inspirations for FastHTML. We are fans of its developer experience and tried to make FastHTML extremely familiar for FastAPI users. FastAPI is designed for creating APIs, whereas FastHTML is designed for creating HTML (i.e "Hypermedia applications"). Anything you could create with FastAPI (plus a JS frontend), you could also create with FastHTML, and vice versa -- if you prefer mainly writing JS, you might prefer FastAPI, since you can move a lot of client-side logic into the JS. If you prefer mainly writing Python, you'll probably want to use FastHTML, since you can often avoid using JS entirely.

FastHTML is specifically designed to make writing modern SPA apps as fast and easy as possible, whilst also ensuring the apps you write are scalable and performant. By default, FastHTML routes return lightweight "partials" that update the DOM directly, rather than doing a full page refresh.

HTMX is best thought of as filling in the missing bits of a web browser -- in fact, web browser manufacturers are considering incorporating similar features directly into future browsers. It is a small javascript library that with a single line of HTML lets you respond to any event from any part of a web page by modifying the DOM in any way you like, all directly from Python. Whilst you don't have to use it with FastHTML, it will dramatically increase the amount of stuff you can do!

No, and yes! You can write nearly any standard web app with just Python. However, using a bit of JS can be helpful -- for instance, nearly any existing JS lib can be incorporated into a FastHTML app, and you can sprinkle bits of JS into your pages anywhere you like.

It depends. Apps using FastHTML and HTMX are often faster than JS-based approaches using big libraries, since they can be very lightweight.

LOVE IS IN THE AIR

What the experts say

Top web programmers tell us that they love working with FastHTML.

© 2024 onwards AnswerDotAI. All rights reserved.