Skip to content
Snippets Groups Projects
Unverified Commit bc1deea3 authored by Joschua Kesper's avatar Joschua Kesper
Browse files

Added `--local` option for easier testing

parent 3584e3fe
No related branches found
No related tags found
No related merge requests found
Pipeline #253243 passed
mod markov;
use std::{fs, path::Path};
use std::{fs, path::Path, net::Ipv4Addr};
use anyhow::Result;
use clap::{arg, Parser};
......@@ -58,19 +58,24 @@ impl Api {
struct Args {
#[arg(short, long)]
file: String,
#[arg(short, long)]
local: bool,
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
let service = OpenApiService::new(Api::from_file(Args::parse().file)?, "mew", "1.0")
let args = Args::parse();
let service = OpenApiService::new(Api::from_file(args.file)?, "mew", "1.0")
.server("http://czi.wtf");
let app = Route::new()
.nest("/", service.clone())
.nest("/docs", service.clone().swagger_ui());
println!("starting server on http://0.0.0.0:6969");
Server::new(TcpListener::bind("0.0.0.0:6969"))
let bind_ip = if args.local { Ipv4Addr::new(127,0,0,1) } else { Ipv4Addr::new(0,0,0,0)};
println!("starting server on http://{}:6969", bind_ip);
Server::new(TcpListener::bind((bind_ip, 6969)))
.run(app)
.await?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment