Back to Browse

1 FastAPI + Flet Integration: Running UI and API on a Single FastAPI Server

365 views
Jan 8, 2026
16:59

New tutorial series on using FastAPI and Flet together in a single Python application. In this first tutorial, we focus on the core architectural setup: running both a FastAPI backend and a Flet UI from one FastAPI instance. Rather than relying on Flet’s default server behavior, we take a more explicit approach by mounting the Flet application directly into FastAPI and managing its lifecycle using FastAPI’s built-in lifespan system. What you’ll learn in this video: - How to create a minimal FastAPI backend with a JSON API endpoint - How to build and test a standalone Flet UI - How to use an async context manager to start and shut down Flet cleanly - How to register the Flet lifecycle with FastAPI’s lifespan context - How to mount the Flet app onto FastAPI using app.mount() - How to run everything together using Uvicorn and ASGI The result is a single FastAPI server that: - Serves API routes (e.g. /api/hello) - Serves the Flet UI on the default route - Manages startup and shutdown correctly for both components Tooling and setup notes: - Python 3.13 - uv for dependency and project management (not pip) - FastAPI, Flet (desktop/web), HTTPX, and Uvicorn In the next video, we’ll connect the two sides by making HTTPX requests from the Flet UI to the FastAPI backend and displaying live data in the interface. This course is designed to be incremental and practical, so each video builds directly on the previous one.

Download

0 formats

No download links available.

1 FastAPI + Flet Integration: Running UI and API on a Single FastAPI Server | NatokHD