Add "create" template
This commit is contained in:
parent
822cf5b037
commit
56544cd0d4
6 changed files with 916 additions and 41 deletions
|
@ -1,6 +1,20 @@
|
|||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
|
||||
use rocket::{get, routes};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use rocket::{get, request::FlashMessage, routes};
|
||||
use rocket_contrib::templates::Template;
|
||||
|
||||
#[get("/create")]
|
||||
fn create_form(flash: Option<FlashMessage>) -> Template {
|
||||
let mut context = HashMap::new();
|
||||
|
||||
if let Some(ref msg) = flash {
|
||||
context.insert("flash", msg.msg());
|
||||
}
|
||||
|
||||
Template::render("create", &context)
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> &'static str {
|
||||
|
@ -8,5 +22,8 @@ fn index() -> &'static str {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
rocket::ignite().mount("/", routes![index]).launch();
|
||||
rocket::ignite()
|
||||
.mount("/", routes![index, create_form])
|
||||
.attach(Template::fairing())
|
||||
.launch();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue