templating

This commit is contained in:
zoe 2022-01-15 16:14:29 +01:00
parent f12764139a
commit caa2535827
2 changed files with 7 additions and 3 deletions

BIN
kitchen-wisdom Executable file

Binary file not shown.

View file

@ -6,8 +6,9 @@ extern crate lazy_static;
use clap::Parser; use clap::Parser;
use markov::Chain; use markov::Chain;
use std::{ use std::{
collections::HashMap,
fs::File, fs::File,
io::{BufRead, BufReader}, collections::HashMap, io::{BufRead, BufReader},
}; };
lazy_static! { lazy_static! {
@ -17,7 +18,8 @@ lazy_static! {
#[get("/")] #[get("/")]
fn index() -> Template { fn index() -> Template {
let context: HashMap<&str, String> = [("wisdom", CHAIN.generate_str())].iter().cloned().collect(); let context: HashMap<&str, String> =
[("wisdom", CHAIN.generate_str())].iter().cloned().collect();
Template::render("index", context) Template::render("index", context)
} }
@ -25,7 +27,9 @@ fn index() -> Template {
fn rocket() -> _ { fn rocket() -> _ {
let mut config = rocket::Config::default(); let mut config = rocket::Config::default();
config.port = ARGS.port; config.port = ARGS.port;
rocket::custom(config).attach(Template::fairing()).mount("/", routes![index]) rocket::custom(config)
.attach(Template::fairing())
.mount("/", routes![index])
} }
fn build_chain() -> Chain<String> { fn build_chain() -> Chain<String> {