init wasm live reload example

This commit is contained in:
Yoshua Wuyts 2020-05-31 17:58:17 +02:00
parent afe91242de
commit cbfcaed9fb
2 changed files with 19 additions and 0 deletions

View File

@ -51,6 +51,7 @@ surf = { version = "2.0.0-alpha.3", default-features = false, features = ["h1-cl
serde = { version = "1.0.102", features = ["derive"] }
criterion = "0.3.1"
tempdir = "0.3.7"
html-index = "0.3.2"
[[test]]
name = "nested"

18
examples/wasm_server.rs Normal file
View File

@ -0,0 +1,18 @@
use tide::{log, Request, Response};
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
log::start();
let mut app = tide::new();
app.at("/").get(serve_html);
app.at("/src").serve_dir("target/")?;
app.listen("127.0.0.1:8080").await?;
Ok(())
}
async fn serve_html(_: Request<()>) -> tide::Result {
let html = html_index::new()
.title("Tide live-reloading WASM server example");
Ok(Response::from_res(html))
}