Clone, run, and explore this sample
This sample demonstrates integrating a FastAPI (Python) app and a JavaScript frontend using Aspire.
AppHost
The entry point that composes every resource and dependency in this sample's distributed application.
#pragma warning disable ASPIREBROWSERLOGS001#pragma warning disable ASPIREJAVASCRIPT001
#:sdk Aspire.AppHost.Sdk@13.4.0#:package Aspire.Hosting.JavaScript@13.4.0#:package Aspire.Hosting.Browsers@13.4.0-preview.1.26281.18#:package Aspire.Hosting.Python@13.4.0#:package Aspire.Hosting.Redis@13.4.0
var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedis("cache");
var app = builder.AddUvicornApp("app", "./app", "main:app") .WithUv() .WithExternalHttpEndpoints() .WithReference(cache) .WaitFor(cache) .WithHttpHealthCheck("/health");
builder.AddViteApp("frontend", "./frontend") .WithReference(app) .WaitFor(app) .WithBrowserLogs() .PublishAsStaticWebsite("/api", app);
builder.Build().Run();The sample consists of two apps:
- app: This is a simple FastAPI-based Python app that returns randomly generated weather forecast data.
- frontend: This is a Vite-based React app that renders the weather forecast data.
Prerequisites
Section titled Prerequisites- Aspire development environment
- Python - at least version 3.13
- Node.js - at least version 22.21.1
- .NET 10 SDK
Running the app
Section titled Running the appIf using the Aspire CLI, run aspire run from this directory.
If using VS Code, open this directory as a workspace and launch the apphost.cs C# file using either the Aspire or C# debuggers.