Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Sample repository demonstrating how to use FastAPI to serve HTML web apps.
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.
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.
TemplateResponse objects from Starlette.poetry install), making the setup reproducible.poetry run uvicorn src.html:app --reload, which auto-reloads on code changes./form endpoint is included at http://127.0.0.1:8000/form, demonstrating how to render a form template and process submissions./form example to capture user input and render results dynamically.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.
fastapi-html is a free, open-source sample repository on GitHub. There are no fees or paid tiers.
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.
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.
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.
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.
