You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1002 B
Rust

#[macro_use] extern crate rocket;
#[macro_use] extern crate serde_derive;
extern crate serde_json;
extern crate rocket_dyn_templates;
mod routes;
mod helpers;
mod data;
use std::{env, process};
use routes::{block, transaction, address, search, home};
use rocket::fs::{FileServer, relative};
use rocket_dyn_templates::Template;
#[launch]
fn rocket() -> _ {
let node = env::var("DAEMON_URI");
match node {
Ok(_) => println!("[+] Using node {:?}", node),
Err(_) => {
println!("[!] Provide a node via env DAEMON_URI");
process::exit(1);
}
}
rocket::build()
.attach(Template::fairing())
.mount("/", routes![home::home])
.mount("/block", routes![block::height, block::hash])
.mount("/transaction", routes![transaction::hash, transaction::receipt])
.mount("/address", routes![address::show])
.mount("/search", routes![search::show])
.mount("/", FileServer::from(relative!("static")))
}