diff options
author | cel 🌸 <cel@blos.sm> | 2023-01-15 21:43:21 +0000 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2023-01-15 21:43:21 +0000 |
commit | 1280b8d6a2a3f2a02179a1e51aef1891a04cc8dd (patch) | |
tree | a5abd1d1855d2d1123586d50e58567096c7dd695 /src/main.rs | |
parent | 4a860896c21220b2b8b22da4a5d2f8794c90253a (diff) | |
download | blossom-1280b8d6a2a3f2a02179a1e51aef1891a04cc8dd.tar.gz blossom-1280b8d6a2a3f2a02179a1e51aef1891a04cc8dd.tar.bz2 blossom-1280b8d6a2a3f2a02179a1e51aef1891a04cc8dd.zip |
set up rocket server
Diffstat (limited to '')
-rw-r--r-- | src/main.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..65a40c4 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,46 @@ +use rocket::fs::{relative, FileServer}; +use rocket::{response::Responder, serde::json::Json}; +use rocket_dyn_templates::{context, Template}; + +#[macro_use] +extern crate rocket; + +#[get("/")] +async fn home() -> Template { + Template::render("home", context! { is_live: true, is_scrobbling: true }) +} + +#[get("/contact")] +async fn contact() -> Template { + Template::render("contact", context! {}) +} + +// #[get("/test")] +// async fn test() -> Result<Template, BlossomError> { +// let posts = reqwest::get("https://skinnyver.se/api/v1/accounts/cel/statuses").await; +// posts +// } + +#[tokio::main] +async fn main() -> Result<(), rocket::Error> { + let _rocket = rocket::build() + .attach(Template::fairing()) + .mount("/", routes![home, contact]) + .mount("/", FileServer::from(relative!("static"))) + .launch() + .await?; + + Ok(()) +} + +#[derive(Responder)] +enum BlossomError { + #[response(status = 500)] + Reqwest(&'static str, #[response(ignore)] reqwest::Error), +} + +impl From<reqwest::Error> for BlossomError { + fn from(e: reqwest::Error) -> Self { + BlossomError::Reqwest("reqwest error", e) + } +} |