diff --git a/src/main.rs b/src/main.rs index bc3534b..36ee637 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,23 +4,25 @@ use std::fs; use std::string::{String}; use std::str; -fn get_page() -> String { +fn get_page(request: String) -> String { // To-do: Make this able to load other pages // // The loaded page should be left immutable as it does // not need to be modified by the server. - let filename = "index.html"; // BAD!!! - let page = fs::read_to_string(filename) - .expect("Page read failed!"); + let mut filename = "index.html"; - return page; + let page = fs::read_to_string(filename); + match page { + Ok(i) => i.to_string(), + Err(e) => "
The resource you are trying to locate cannot be accessed!
".to_string(), + } } -fn read_stream(mut stream: TcpStream) -> Result