This project is a technology demonstration for server-side rendering with Python, FastAPI, and htmx; in the disguise of an AI chatbot that responds to questions about beer and coffee. More specifically the project showcases the following libraries:
- FastAPI: A modern, async, Python web framework.
- FastHX: Server-side rendering utility with HTMX support for FastAPI.
- htmy: A powerful, async, pure-Python server-side rendering engine.
- htmx: A JavaScript library for making AJAX requests and DOM updates using HTML attributes.
Importantly, the project does not use Jinja or any other traditional templating engine. Instead, it uses htmy – in some cases with plain html and markdown snippets with no custom templating syntax –, so you can enjoy all the benefits of modern IDEs, linters, static code analysis tools, and coding assistants.
Styling is done with TailwindCSS v4 and DaisyUI v5, but the project is not a TailwindCSS or DaisyUI demo, the focus is entirely on server-side rendering.
Need help kickstarting a new project with this or a similar toolchain? Get in touch!
For a seamless experience, you need uv to be installed. If not available, you can find the required dependencies in pyproject.toml.
With uv in place, all you need to do is run uv run uvicorn app.main:app --reload and open http://127.0.0.1:8000/ in your browser.
uv run tools:
- Linting:
ruff check .orruff check . --fix - Formatting:
ruff format .orruff format . --checkfor format check. - Static type analysis:
uv run mypy .
poethepoet is a development dependency of the project. You can check available tasks by running uv run poe.
vercel.json contains the configuration for deployment on Vercel.
The Vercel Python runtime only supports requirements.txt. The requirements file can be generated with uv export --no-dev > requirements.txt. It must be done manually before every push to the main branch.
The Vercel Python runtime is experimental at this time (March 2025), so this config may become outdated relatively soon.
- fastapi-htmx-tailwind-example: A similar, but slightly outdated technology demonstration using Jinja and MongDB, with more focus on HTMX.
The package is open-sourced under the conditions of the MIT license.