add serve_file to example

This commit is contained in:
Mendelt Siebenga 2020-10-21 22:47:19 +02:00
parent f1a82385ae
commit a4a9e57a2e
2 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<html>
<head><title>Example</title></head>
<body>
<h1>Example</h1>
</body>
</html>

View File

@ -4,6 +4,7 @@ async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async { Ok("visit /src/*") });
app.at("/src").serve_dir("src/")?;
app.at("/example").serve_file("examples/static_file.html")?;
app.listen("127.0.0.1:8080").await?;
Ok(())
}