Skip to content

Can I service static html with include_str! macro (ie include it in my binary)? #2989

Answered by robjtede
AnatolyBuga asked this question in Q&A
Discussion options

You must be logged in to vote
let index = include_str!("./index.html");

HttpResponse::Ok()
  .content_type(ContentType::html())
  .body(index)

# or from actix-web-lab
Html::new(index)

If there's more files you want to include statically, there's this lib: https://docs.rs/actix-web-static-files

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AnatolyBuga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants