From db32d8b07e61c9cc316355400d15172fa10d342c Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Fri, 11 Nov 2022 20:01:58 +0530 Subject: [PATCH] Basic run with tera templating Signed-off-by: baalajimaestro --- src/main.rs | 38 ++++++++++++++++++++++++-------------- templates/base.html | 11 +++++++++++ templates/paste.html | 5 +++++ 3 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 templates/base.html create mode 100644 templates/paste.html diff --git a/src/main.rs b/src/main.rs index f3f7914..64f25e5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,26 +1,36 @@ -use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; +use actix_web::{get, App, HttpResponse, HttpServer, Responder, web::{Data}}; +use tera::{Tera, Context}; -#[get("/")] -async fn hello() -> impl Responder { - HttpResponse::Ok().body("Hello world!") +struct Template { + paste: Tera, } -#[post("/echo")] -async fn echo(req_body: String) -> impl Responder { - HttpResponse::Ok().body(req_body) -} -async fn manual_hello() -> impl Responder { - HttpResponse::Ok().body("Hey there!") +#[get("/{paste_id}")] +async fn paste_render(data: Data