Static files in Rocket

Published: May 27, 2024

Rocket FileServer

use rocket::fs::FileServer;

#[launch]
fn rocket() -> _ {
    rocket::build()
         // serve files from `/www/static` at path `/public`
        .mount("/public", FileServer::from("/www/static"))
}

Comments • 1

  • Oneself

    How would you serve a static file for a specific path request?

    • Eduardo

      Upcoming publication on how.