Add "create" template

This commit is contained in:
finga 2021-01-12 02:10:48 +01:00
parent 822cf5b037
commit 56544cd0d4
6 changed files with 916 additions and 41 deletions

View file

@ -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();
}