````rust
use std::collections::HashMap;
use simple_ssr_rs::{SSRender,ssr_work,Value};
use simple_ssr_rs::salvo::{self,prelude::*};
// Extend router
struct Hello(TeraBuilder);
#[handler]
impl Hello{
async fn handle(&self, req: &mut Request, _depot: &mut Depot, res: &mut Response){
//let mut ctx = Context::default();
// let ctx = self.0.gen_context(req);
// match self.0.build(ctx.clone()){
// Ok((tera,ctx))=>{
// let r = tera.render("index.html", &ctx).unwrap_or("".to_owned());
// let _ = res.add_header("server", "xfinal", true);
// res.render(Text::Html(r));
// }
// Err(_)=>{
// res.render(Text::Plain("Error"));
// }
// }
res.render(Text::Plain("Hello"));
}
}
#[handler]
async fn handle404(&self, _req: &Request, _depot: &Depot, res: &mut Response, ctrl: &mut FlowCtrl) {
if let Some(StatusCode::NOT_FOUND) = res.status_code {
res.render("Custom 404 Error Page");
ctrl.skip_rest();
}
}
fn main() {
let mut ssr = SSRender::new("0.0.0.0:8080");
ssr.set_pub_dir_name("assets"); // specify the name of the public assets directory in the current root directory
ssr.set_tmpl_dir_name("pages"); // specify the name of the template directory in the current root directory
// ssr.set_meta_info_collector(|req:&Request|->HashMap<String, Value>{}); // get meta data from the current request for the tempalte
Ok(Value::String(format!("<p>{r}</p><br/>")))
});
#### Use built-in function
````html
<div>
{{ include_file(path="common/abc.html"), context=`{"title":"abc"}` | safe }}
</div>
````
Then we can access the website on the browser: http://localhost:8080/ or http://localhost:8080/index.html. Access the static resource on browser: http://localhost:8080/assets/filename
More details about how to use the template engine can be seen on the home page of [Tera](https://tera.netlify.app/docs/).