Move web server code into server module.
This commit is contained in:
1 parent
01ebdf710e
commit
a54e7a341b
2 files changed
+16
-6
No files matched your search
+2
-6
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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!"
|
||||
}
|
||||
Reference in new issue
Block a user