noun
/ˈhɪr.oʊ/
cd
to the path containing
the templates and style folders before running or you will get a file-not-found error!Let's start with dependencies:
sh
cargo new hyro-getting-started
cargo add hyro
cargo add axum
cargo add tokio -F full
mkdir templates
HYRO templates use Jinja2. Let's start with a basic one:
templates/hello.html.jinja2
```html
Hello, {{ name }}!
```
Then we can set up our boilerplate:
src/main.rs
```rust use hyro::{context, RouterExt, Template};
async fn main() { let router = axum::Router::new() .route("/hello", axum::routing::get(hello)) .intoservicewith_hmr();
axum::Server::from_tcp(hyro::bind("0.0.0.0:1380").await)).unwrap() .serve(router) .await .unwrap(); }
async fn hello(template: Template) -> axum::response::Html { template.render(context! { name => "World", }) } ```
Now if we navigate to 'localhost:1380/hello', we can read our message! If you're running in
debug mode, you can edit templates/hello.html.jinja2
and the HMR should kick in.