This is how I'm embedding files in a Rust binary and servering them with axum. Doing so means it's not necessary to have them on the file system when the server is run.
Single File
---[dependencies]
axum ="0.8.0"
tokio ={ version ="1.44.2", features =["macros","rt-multi-thread"]}---useaxum::{Router,response::Html,routing::get};#[tokio::main]
async fnmain(){let app =Router::new().route("/",get(serve_home_page));let listener =tokio::net::TcpListener::bind("0.0.0.0:4545").await.unwrap();axum::serve(listener, app).await.unwrap();}
async fnserve_home_page()->Html<&'staticstr>{let response =include_str!("files/index.html");
Html(response)}
A Directory
(Note that you can't do this for the root of the site)