Stub in Axum templating
This commit is contained in:
parent
70842b1db2
commit
856482ce17
|
|
@ -7,4 +7,6 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
tokio = { version = "1", features = ["rt-multi-thread"]}
|
||||
axum = "0.7"
|
||||
axum = "0.7"
|
||||
askama = "0.12"
|
||||
askama_axum = "0.4"
|
||||
|
|
|
|||
11
src/main.rs
11
src/main.rs
|
|
@ -1,3 +1,4 @@
|
|||
use askama::Template;
|
||||
use axum::{routing::get, Router};
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -9,6 +10,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn root() -> &'static str {
|
||||
"It works!"
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate<'a> {
|
||||
title: &'a str,
|
||||
}
|
||||
|
||||
async fn root<'a>() -> IndexTemplate<'a> {
|
||||
IndexTemplate { title: "LocalHub" }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>{{title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
It still works!
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue