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
aae7584df8
commit
f12764139a
8 changed files with 23695 additions and 40 deletions
11
src/main.rs
11
src/main.rs
|
@ -1,12 +1,13 @@
|
|||
#[macro_use]
|
||||
extern crate rocket;
|
||||
use rocket_dyn_templates::Template;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
use clap::Parser;
|
||||
use markov::Chain;
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
io::{BufRead, BufReader}, collections::HashMap,
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
|
@ -15,16 +16,16 @@ lazy_static! {
|
|||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> String {
|
||||
CHAIN.generate_str()
|
||||
fn index() -> Template {
|
||||
let context: HashMap<&str, String> = [("wisdom", CHAIN.generate_str())].iter().cloned().collect();
|
||||
Template::render("index", context)
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
let mut config = rocket::Config::default();
|
||||
config.port = ARGS.port;
|
||||
rocket::custom(config).mount("/", routes![index])
|
||||
//rocket::build().mount("/", routes![index])
|
||||
rocket::custom(config).attach(Template::fairing()).mount("/", routes![index])
|
||||
}
|
||||
|
||||
fn build_chain() -> Chain<String> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue