From 07eb95071b81fe07c5163e75b50359e386a0f1eb Mon Sep 17 00:00:00 2001 From: Jared Burce Date: Tue, 17 Mar 2020 11:57:45 -0700 Subject: [PATCH] Hello warp static file serve --- Cargo.toml | 5 +++++ src/main.rs | 20 ++++++++++++++++++-- static/index.html | 8 ++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 static/index.html diff --git a/Cargo.toml b/Cargo.toml index ddead95..87dc2b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,8 @@ authors = ["Jared Burce "] edition = "2018" [dependencies] +warp = "0.2" +webrtc-unreliable = "0.4" +tokio = "0.2" +futures = "0.3" +pretty_env_logger = "0.4" diff --git a/src/main.rs b/src/main.rs index e7a11a9..d06007a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,19 @@ -fn main() { - println!("Hello, world!"); +// use tokio::prelude::*; +use warp::Filter; + +fn main() -> Result<(), Box> { + pretty_env_logger::init(); + + let mut rt = tokio::runtime::Runtime::new()?; + rt.block_on(async { + let root = warp::get() + .and(warp::path::end()) + .and(warp::fs::file("./static/index.html")); + + let routes = root; + + warp::serve(routes).run(([127, 0, 0, 1], 8060)).await; + }); + + Ok(()) } diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..bbaaf9a --- /dev/null +++ b/static/index.html @@ -0,0 +1,8 @@ + + + Hello, World! + + + Hello, Warp! + +