furas

Rust - Iron - minimal web server with extra Header (Stackoverflow)

Mar 15th, 2026
63
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.55 KB | None | 0 0
  1. // Stackoverflow: [Staging Ground: Petit soucis en compilation sur Rust - Stack Overflow](https://stackoverflow.com/staging-ground/79907982)
  2.  
  3. use iron::prelude::*;
  4. use iron::status;
  5. use iron::headers::ContentType;
  6. use iron::modifiers::Header;
  7.  
  8. fn main() {
  9.     println!("Server running at http://localhost:3000");
  10.     Iron::new(get_form).http("localhost:3000").unwrap();
  11. }
  12.  
  13. fn get_form(_req: &mut Request) -> IronResult<Response> {
  14.     Ok(Response::with((
  15.         status::Ok,
  16.         Header(ContentType::html()),
  17.         "<h1>Hello</h1>"
  18.     )))
  19. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment