diff --git a/src/main.rs b/src/main.rs index ba37918..4af5e28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ pub mod args; pub mod layers; pub mod mushroom; pub mod render; +pub mod server; pub mod translate; use std::fs::OpenOptions; @@ -12,18 +13,13 @@ use clap::Parser; #[macro_use] extern crate rocket; -#[get("/")] -fn hello() -> &'static str { - "Hello, world!" -} - #[rocket::main] async fn main() { let args = args::Args::parse(); if args.run_server { // If we run as a server, ignore other arguments. - let _ = rocket::build().mount("/", routes![hello]).launch().await; + server::run_server().await; return; } diff --git a/src/server.rs b/src/server.rs new file mode 100644 index 0000000..9dc76d2 --- /dev/null +++ b/src/server.rs @@ -0,0 +1,14 @@ +extern crate approx; + +pub async fn run_server() { + rocket::build() + .mount("/", routes![hello]) + .launch() + .await + .unwrap(); +} + +#[get("/")] +pub fn hello() -> &'static str { + "Hello, world!" +}