update comments
This commit is contained in:
parent
1a3e648dcd
commit
eedf62b46c
1 changed files with 3 additions and 8 deletions
11
src/main.rs
11
src/main.rs
|
@ -10,7 +10,7 @@ use tera::Tera;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// build our application with a single route
|
||||
// application routes
|
||||
let app = Router::new()
|
||||
.route("/", get(index))
|
||||
.route("/search", get(search))
|
||||
|
@ -24,12 +24,8 @@ async fn main() {
|
|||
}
|
||||
|
||||
async fn index() -> impl IntoResponse {
|
||||
// Create a new Tera instance and add a template from a string
|
||||
let tera = tera_create();
|
||||
// Prepare the context with some data
|
||||
let context = tera::Context::new();
|
||||
|
||||
// Render the template with the given context
|
||||
let rendered = tera.render("index.html", &context).unwrap();
|
||||
|
||||
header(rendered)
|
||||
|
@ -37,12 +33,11 @@ async fn index() -> impl IntoResponse {
|
|||
|
||||
async fn search(Query(params): Query<HashMap<String, String>>) -> impl IntoResponse {
|
||||
let tera = tera_create();
|
||||
// Prepare the context with some data
|
||||
let mut context = tera::Context::new();
|
||||
context.insert("query", params.get("q").unwrap());
|
||||
|
||||
let rendered = tera.render("search.html", &context).unwrap();
|
||||
|
||||
context.insert("query", params.get("q").unwrap());
|
||||
|
||||
header(rendered)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue