summaryrefslogtreecommitdiff
path: root/crates/web/src/main.rs
blob: d80b23251f73e7d0ddd06fa316e4c67df6b2e124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::sync::Arc;

use axum::{routing::get, Router};

pub use argonaut_control::Handle as PrinterThread;
use tracing::info;

#[tokio::main(flavor = "current_thread")]
async fn main() {
    tracing_subscriber::fmt::init();

    let printer_thread = PrinterThread::spawn();
    let printer_thread = Arc::new(printer_thread);

    let app = Router::new()
        .route("/", get(root))
        .with_state(printer_thread);
    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();

    info!("init completed, listening");
    axum::serve(listener, app).await.unwrap();
}

async fn root() -> &'static str {
    "Hello, World!"
}