From 0b1563bc56cf20f8a63d5b90783294a1eb11ea17 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 22 Apr 2021 02:17:34 -0600 Subject: get rolling with HTTP and templates --- src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index e7a11a9..cb18c22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,18 @@ -fn main() { - println!("Hello, world!"); +use askama::Template; +use tide::prelude::*; + +#[derive(Template)] +#[template(path = "index.html")] +struct IndexTemplate; + +#[async_std::main] +async fn main() -> tide::Result<()> { + let mut app = tide::new(); + app.at("/").get(index); + app.listen("127.0.0.1:8000").await?; + Ok(()) +} + +async fn index(_: tide::Request<()>) -> tide::Result { + Ok(IndexTemplate.into()) } -- cgit v1.2.3