fastapi-html is a sample GitHub repository that demonstrates how to serve HTML web apps built with Jinja2 templates using the FastAPI Python web framework. Maintained by Eugene Yan, it pairs a minimal codebase with a 2-minute blog post that walks through setup.
What is fastapi-html?
fastapi-html is a starter project that shows FastAPI returning server-rendered HTML instead of JSON. The repository contains a small src/html.py module that defines an application instance and at least one route, /form, which renders a Jinja2 template. Inputs are HTTP requests; outputs are complete HTML pages generated on the server. The project runs on Python 3, uses Poetry to manage dependencies, and launches through the Uvicorn ASGI server. As of its metadata, the repository has 76 stars on GitHub.
Key Features
- FastAPI backend — The core framework is FastAPI, with routes defined in Python and responses returned as
TemplateResponseobjects from Starlette. - Jinja2 templating — HTML templates are rendered server-side with Jinja2, allowing dynamic data and form handling without a separate frontend build step.
- Poetry dependency management — The project uses Poetry for installing dependencies (
poetry install), making the setup reproducible. - Uvicorn development server — The quickstart start command is
poetry run uvicorn src.html:app --reload, which auto-reloads on code changes. - Example form route — A
/formendpoint is included athttp://127.0.0.1:8000/form, demonstrating how to render a form template and process submissions. - Companion blog tutorial — The repository links to a 2-minute blog post on eugeneyan.com explaining how to set up HTML apps with FastAPI, Jinja, forms, and templates.
- Minimal footprint — The sample is intentionally small, making it easy to read the entire codebase and adapt it.
Who is it for?
- Python developers — who want to see a concrete example of FastAPI serving HTML pages rather than building an API-only service.
- Developers new to server-side rendering — who need a small, readable template to learn how Jinja2 and FastAPI fit together.
- Hobbyists and learners — who are following the companion blog post and want working code alongside the tutorial.
Use cases
- Learning FastAPI templating — Study the route definitions and template calls to understand FastAPI's integration with Jinja2.
- Bootstrapping simple web tools — Use the repo as a starting point for internal dashboards or small form-based applications that don't need a JavaScript frontend.
- Prototyping form flows — Extend the
/formexample to capture user input and render results dynamically.
How does fastapi-html work?
The quickstart involves three commands: clone the repository, run poetry install to install dependencies, and start the application with poetry run uvicorn src.html:app --reload. Then you navigate to http://127.0.0.1:8000/form to see the rendered form. The source code defines a FastAPI app with a route that returns a Jinja2 template.
Pricing
fastapi-html is a free, open-source sample repository on GitHub. There are no fees or paid tiers.
FAQ
Does fastapi-html require a separate frontend framework?
No. It uses Jinja2 templates rendered on the server, so no JavaScript framework like React or Vue is needed. The HTML is generated entirely by FastAPI and Jinja2.
How do I run fastapi-html on my machine?
You need Python and Poetry installed. Then clone the repository, run poetry install, and start the server with poetry run uvicorn src.html:app --reload. Open http://127.0.0.1:8000/form in your browser.
Is this project actively maintained?
The repository is a sample/demo; it has 76 stars and is accompanied by a blog post. There's no evidence of active maintenance, but it serves as a reference example.
Can I use this for production applications?
It's a minimal sample intended for learning. For production, you'd likely add more structure, security, and testing. The repository itself doesn't claim production readiness.








