Hello warp static file serve
This commit is contained in:
@@ -5,3 +5,8 @@ authors = ["Jared Burce <jaredr@gmail.com>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
warp = "0.2"
|
||||||
|
webrtc-unreliable = "0.4"
|
||||||
|
tokio = "0.2"
|
||||||
|
futures = "0.3"
|
||||||
|
pretty_env_logger = "0.4"
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -1,3 +1,19 @@
|
|||||||
fn main() {
|
// use tokio::prelude::*;
|
||||||
println!("Hello, world!");
|
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(())
|
||||||
}
|
}
|
||||||
|
|||||||
8
static/index.html
Normal file
8
static/index.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hello, World!</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Hello, Warp!
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user