The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Serve A Local Directory With axum

TODO: Pull subtitle into page object
Code
[package]
name = "axum_serve_directory"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = "0.6.20"
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros"] }
tower-http = { version = "0.4.4", features = ["fs"] }

Code
use axum::Router;
use std::net::SocketAddr;
use std::path::Path;
use tower_http::services::ServeDir;

#[tokio::main]
async fn main() {
    let addr = SocketAddr::from(([127, 0, 0, 1], 3313));
    let app = Router::new().nest_service("/", ServeDir::new(Path::new("html")));
    axum::Server::bind(&addr)
        .serve(app.into_make_service())
        .await
        .unwrap();
}

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Serve A Local Directory With axum

-- code
-- name: Cargo.toml

[package]
name = "axum_serve_directory"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = "0.6.20"
tokio = { version = "1.32.0", features = ["rt-multi-thread", "macros"] }
tower-http = { version = "0.4.4", features = ["fs"] }



-- code
-- name: src/main.rs

use axum::Router;
use std::net::SocketAddr;
use std::path::Path;
use tower_http::services::ServeDir;

#[tokio::main]
async fn main() {
    let addr = SocketAddr::from(([127, 0, 0, 1], 3313));
    let app = Router::new().nest_service("/", ServeDir::new(Path::new("html")));
    axum::Server::bind(&addr)
        .serve(app.into_make_service())
        .await
        .unwrap();
}


-- categories
-- Rust  
-- axum

-- metadata
-- date: 2023-09-07 20:43:24
-- id: 2v5lqoy7
-- site: aws
-- type: post
-- status: scratch