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