Add placeholder --run-server support.

This allows the program to run as a web server,
which will eventually be able to return
mushroom models.
This commit is contained in:
dongar committed 2024-06-27 10:42:55 -05:00
1 parent 220d041975
commit 01ebdf710e
4 files changed
+1458 -30

No files matched your search

Generated
+1437 -29
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
approx = "0.5.1"
clap = { version = "4.5.4", features = ["derive"] }
rocket = "0.5.1"
serde = "1.0.203"
serde_derive = "1.0.203"
stl_io = "0.7.0"
+4
View File
@@ -8,6 +8,10 @@ pub struct Args {
#[arg(long, default_value = "mesh.stl")]
pub output: String,
/// Shape of the cap.
#[arg(long, default_value_t = false)]
pub run_server: bool,
/// Height of total mushroom in millimeters.
#[arg(long, default_value_t = 100)]
pub height: u32,
+16 -1
View File
@@ -9,9 +9,24 @@ use std::fs::OpenOptions;
extern crate approx;
use clap::Parser;
fn main() {
#[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;
return;
}
// Define the mushroom.
let mushroom = args.mushroom_from_args();