39 lines
793 B
Rust
39 lines
793 B
Rust
#[macro_use]
|
|
extern crate rocket;
|
|
#[macro_use]
|
|
extern crate lazy_static;
|
|
|
|
use clap::Parser;
|
|
use rocket::fs::{relative, FileServer};
|
|
use rocket_dyn_templates::Template;
|
|
|
|
mod names;
|
|
mod rooms;
|
|
|
|
lazy_static! {
|
|
static ref ARGS: Args = Args::parse();
|
|
}
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[clap(about, version, author)]
|
|
struct Args {
|
|
// Port number for server
|
|
#[clap(short, long, default_value_t = 8000)]
|
|
port: u16,
|
|
}
|
|
|
|
#[launch]
|
|
fn rocket() -> _ {
|
|
let mut config = rocket::Config::default();
|
|
config.port = ARGS.port;
|
|
rocket::custom(config)
|
|
.attach(Template::fairing())
|
|
.mount("/", FileServer::from(relative!("static")))
|
|
.mount("/", routes![join])
|
|
}
|
|
|
|
#[get("/?<roomname>")]
|
|
fn join (roomname: &str) -> String {
|
|
format!("You're joining {}", roomname)
|
|
}
|