mirror of
https://git.kittycat.homes/zoe/wisdom.git
synced 2024-08-15 03:26:36 +00:00
templating
This commit is contained in:
parent
f12764139a
commit
caa2535827
2 changed files with 7 additions and 3 deletions
BIN
kitchen-wisdom
Executable file
BIN
kitchen-wisdom
Executable file
Binary file not shown.
10
src/main.rs
10
src/main.rs
|
@ -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> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue