Implement basic templating
This commit is contained in:
parent
234458e11c
commit
1cf099845b
5 changed files with 1317 additions and 85 deletions
14
src/main.rs
14
src/main.rs
|
@ -1,11 +1,19 @@
|
|||
#[macro_use] extern crate rocket;
|
||||
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> &'static str {
|
||||
"Hello, world!"
|
||||
fn index() -> Template {
|
||||
Template::render("index", context! {
|
||||
challenge: 114,
|
||||
})
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build().mount("/", routes![index])
|
||||
let config = rocket::Config::figment()
|
||||
.merge(("port", 1313));
|
||||
rocket::custom(config)
|
||||
.mount("/", routes![index])
|
||||
.attach(Template::fairing())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue