Move web server code into server module.

This commit is contained in:
dongar committed 2024-06-27 11:31:55 -05:00
1 parent 01ebdf710e
commit a54e7a341b
2 files changed
+16 -6

No files matched your search

+2 -6
View File
@@ -2,6 +2,7 @@ pub mod args;
pub mod layers; pub mod layers;
pub mod mushroom; pub mod mushroom;
pub mod render; pub mod render;
pub mod server;
pub mod translate; pub mod translate;
use std::fs::OpenOptions; use std::fs::OpenOptions;
@@ -12,18 +13,13 @@ use clap::Parser;
#[macro_use] #[macro_use]
extern crate rocket; extern crate rocket;
#[get("/")]
fn hello() -> &'static str {
"Hello, world!"
}
#[rocket::main] #[rocket::main]
async fn main() { async fn main() {
let args = args::Args::parse(); let args = args::Args::parse();
if args.run_server { if args.run_server {
// If we run as a server, ignore other arguments. // If we run as a server, ignore other arguments.
let _ = rocket::build().mount("/", routes![hello]).launch().await; server::run_server().await;
return; return;
} }
+14
View File
@@ -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!"
}