# StreamlitAppHostingExtension Methods

- Package: [CommunityToolkit.Aspire.Hosting.Python.Extensions](/reference/api/csharp/communitytoolkit.aspire.hosting.python.extensions.md)
- Type: [StreamlitAppHostingExtension](/reference/api/csharp/communitytoolkit.aspire.hosting.python.extensions/streamlitapphostingextension.md)
- Kind: `Methods`
- Members: `1`

Provides extension methods for adding Streamlit applications to an `Hosting.IDistributedApplicationBuilder`.

## AddStreamlitApp(IDistributedApplicationBuilder, string, string, string)

> **Experimental:** CTASPIRE001 - [Learn more](/diagnostics/ctaspire001/)

- Name: `AddStreamlitApp(IDistributedApplicationBuilder, string, string, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<StreamlitAppResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.Python.Extensions/StreamlitAppHostingExtension.cs#L53-L105)

Adds a Streamlit application to the application model.

```csharp
public static class StreamlitAppHostingExtension
{
    public static IResourceBuilder<StreamlitAppResource> AddStreamlitApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string appDirectory,
        string scriptPath)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the Streamlit application.
- `appDirectory` (`string`)
  The path to the directory containing the Streamlit application.
- `scriptPath` (`string`)
  The path to the Python script to be run by Streamlit (relative to appDirectory).

## Returns

`IResourceBuilder<StreamlitAppResource>` -- An `ApplicationModel.IResourceBuilder`1` for the Streamlit application resource.

## Remarks

This method uses the Aspire.Hosting.Python integration to run Streamlit applications. By default, it uses the `.venv` virtual environment in the app directory. Use standard Python extension methods like `WithVirtualEnvironment`, `WithPip`, or `WithUv` to customize the environment.

**⚠️ EXPERIMENTAL:** This integration is experimental and subject to change. The underlying implementation will be updated to use public APIs when they become available in Aspire.Hosting.Python (expected in Aspire 13.1).

## Examples

Add a Streamlit application to the application model:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

builder.AddStreamlitApp("dashboard", "../streamlit-app", "app.py")
       .WithHttpEndpoint(env: "PORT");

builder.Build().Run();
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
