You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
834 B
36 lines
834 B
mod routes;
|
|
mod utils;
|
|
|
|
use std::{fs, net::SocketAddr};
|
|
|
|
use ai_core::config::Config;
|
|
use axum::{
|
|
routing::{get, post},
|
|
Router,
|
|
};
|
|
use once_cell::sync::Lazy;
|
|
|
|
pub static CONFIG: Lazy<Config> = Lazy::new(|| {
|
|
let config = fs::read_to_string("./config.ron").expect("Failed to read config.ron");
|
|
|
|
ron::from_str(&config).expect("Failed to parse config")
|
|
});
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
tracing_subscriber::fmt::init();
|
|
|
|
let addr: SocketAddr = "0.0.0.0:3000".parse().unwrap();
|
|
let app = Router::new()
|
|
.route("/generate", post(routes::generate))
|
|
.route("/history", get(routes::get_history))
|
|
.route("/ais", get(routes::get_ais));
|
|
|
|
tracing::info!("Listening on {}", addr);
|
|
|
|
axum::Server::bind(&addr)
|
|
.serve(app.into_make_service())
|
|
.await
|
|
.unwrap();
|
|
}
|