Hello warp static file serve

This commit is contained in:
2020-03-17 11:57:45 -07:00
parent 1f077745b8
commit 07eb95071b
3 changed files with 31 additions and 2 deletions

View File

@@ -1,3 +1,19 @@
fn main() {
println!("Hello, world!");
// use tokio::prelude::*;
use warp::Filter;
fn main() -> Result<(), Box<dyn std::error::Error>> {
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(())
}