Server API v1 #1
@ -1,13 +1,31 @@
|
||||
use std::env;
|
||||
|
||||
use actix_web::{App, get, HttpResponse, HttpServer, Responder};
|
||||
|
||||
use crate::util::warn_println;
|
||||
|
||||
mod util;
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
util::print_copyright_notice();
|
||||
|
||||
let port = 8000;
|
||||
let bind_addr = "127.0.0.1";
|
||||
// Default Server Values
|
||||
let mut port = 8000;
|
||||
let mut bind_addr = String::from("127.0.0.1");
|
||||
|
||||
// If env variable for port or bind_addr is present use that instead of default.
|
||||
if let Ok(env_port) = env::var("PORT") {
|
||||
if let Ok(env_port) = env_port.parse::<u16>() {
|
||||
port = env_port;
|
||||
} else {
|
||||
warn_println("Failed to parse PORT env variable using default value.");
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(env_addr) = env::var("BIND_ADDR") {
|
||||
bind_addr = env_addr;
|
||||
}
|
||||
|
||||
util::notice_println(format!("Starting server on {}:{}", bind_addr, port));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user