initial prototype

This commit is contained in:
2025-07-19 15:35:04 +02:00
commit 673a0967b2
8 changed files with 1948 additions and 0 deletions

34
src/main.rs Normal file
View File

@@ -0,0 +1,34 @@
mod downloader;
mod state;
mod streamer;
use axum::{extract::State, routing::get, Router};
use state::AppState;
use std::sync::Arc;
async fn new(State(state): State<Arc<AppState>>) -> &'static str {
let Ok(url) = player::newest_morning_journal_streaming_url().await else {
return "Failed getting latest url";
};
downloader::spawn_download_task(&url, state.clone());
"Download started. Access / to stream the new content."
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let state = Arc::new(AppState::new());
let app = Router::new()
.route("/", get(streamer::stream_handler))
.route("/new", get(new))
.with_state(state);
println!("Streaming server running on http://localhost:3000");
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
axum::serve(listener, app).await?;
Ok(())
}