> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shuttle.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Static Files

> This article walks you through setting up static files with Actix Web, a powerful Rust framework for battle-hardened web applications.

## Description

This example has one route at `/` where the homepage is served and shows you how you can serve HTML or other types of files with Actix Web.

Note that static assets are declared in the `Shuttle.toml` file.

You can clone the example below by running the following (you'll need `shuttle` CLI installed):

```bash theme={null}
shuttle init --from shuttle-hq/shuttle-examples --subfolder actix-web/static-files
```

## Code

```rust src/main.rs theme={null}
use actix_files::Files;
use actix_web::web::ServiceConfig;
use shuttle_actix_web::ShuttleActixWeb;

#[shuttle_runtime::main]
async fn main() -> ShuttleActixWeb<impl FnOnce(&mut ServiceConfig) + Send + Clone + 'static> {
    let config = move |cfg: &mut ServiceConfig| {
        cfg.service(Files::new("/", "assets"));
    };

    Ok(config.into())
}
```

```html assets/index.html theme={null}
<!DOCTYPE html>
<html>
    <head>
        <title>Static Files</title>
    </head>
    <body>
        <p>This is an example of serving static files with Actix Web and Shuttle.</p>
    </body>
</html>
```

```toml Cargo.toml theme={null}
[package]
name = "static-files"
version = "0.1.0"
edition = "2021"

[dependencies]
actix-files = "0.6.2"
actix-web = "4.3.1"
shuttle-actix-web = "0.57.0"
shuttle-runtime = "0.57.0"
tokio = "1.26.0"
```

```toml Shuttle.toml theme={null}
[build]
assets = [
    "assets/*",
]
```

## Usage

After you clone the example, launch it locally by using `shuttle run` then visit the home route at `http://localhost:8000` - you should see a homepage that shows our included HTML file.

You can extend this example by adding more routes that serve other files.

***

<Snippet file="other-frameworks.mdx" />

<Snippet file="check-examples.mdx" />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.