initial commit

This commit is contained in:
glyph 2020-05-08 18:22:06 +01:00
commit f9f54d1b50
5 changed files with 1486 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1407
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

20
Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
[package]
name = "mycelial_technology"
version = "0.1.0"
authors = ["glyph <gnomad@cryptolab.net>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
log = "0.4"
rocket = "0.4"
serde = "1"
serde_derive = "1"
serde_json = "1"
tera = "1"
[dependencies.rocket_contrib]
version = "0.4"
default-features = false
features = ["json", "tera_templates"]

45
src/main.rs Normal file
View File

@ -0,0 +1,45 @@
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate rocket;
extern crate rocket_contrib;
#[macro_use]
extern crate serde_derive;
extern crate tera;
use rocket_contrib::templates::Template;
#[derive(Debug, Serialize)]
struct FlashContext {
flash_name: Option<String>,
flash_msg: Option<String>,
}
#[get("/")]
fn index() -> Template {
let context = FlashContext {
flash_name: None,
flash_msg: None,
};
Template::render("index", &context)
}
#[catch(404)]
fn not_found() -> Template {
debug!("404 Page Not Found");
let context = FlashContext {
flash_name: Some("error".to_string()),
flash_msg: Some("No resource found for given URL".to_string()),
};
Template::render("not_found", context)
}
fn main() {
rocket::ignite()
.mount("/", routes![index])
.register(catchers![not_found])
.attach(Template::fairing())
.launch();
}

13
templates/index.html.tera Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>title</title>
<meta name="author" content="name">
<meta name="description" content="description here">
<meta name="keywords" content="keywords, here">
</head>
<body>
</body>
</html>