update comments

This commit is contained in:
Vri 🌈 2023-11-15 20:03:50 +01:00
parent 1a3e648dcd
commit eedf62b46c
Signed by: vrifox
SSH key fingerprint: SHA256:7OLOvW+jmULkXpdl5rUWgid7WJQhOIEgj+4WP/PtCpI

View file

@ -10,7 +10,7 @@ use tera::Tera;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
// build our application with a single route // application routes
let app = Router::new() let app = Router::new()
.route("/", get(index)) .route("/", get(index))
.route("/search", get(search)) .route("/search", get(search))
@ -24,12 +24,8 @@ async fn main() {
} }
async fn index() -> impl IntoResponse { async fn index() -> impl IntoResponse {
// Create a new Tera instance and add a template from a string
let tera = tera_create(); let tera = tera_create();
// Prepare the context with some data
let context = tera::Context::new(); let context = tera::Context::new();
// Render the template with the given context
let rendered = tera.render("index.html", &context).unwrap(); let rendered = tera.render("index.html", &context).unwrap();
header(rendered) header(rendered)
@ -37,12 +33,11 @@ async fn index() -> impl IntoResponse {
async fn search(Query(params): Query<HashMap<String, String>>) -> impl IntoResponse { async fn search(Query(params): Query<HashMap<String, String>>) -> impl IntoResponse {
let tera = tera_create(); let tera = tera_create();
// Prepare the context with some data
let mut context = tera::Context::new(); let mut context = tera::Context::new();
context.insert("query", params.get("q").unwrap());
let rendered = tera.render("search.html", &context).unwrap(); let rendered = tera.render("search.html", &context).unwrap();
context.insert("query", params.get("q").unwrap());
header(rendered) header(rendered)
} }