remove need to call /new
This commit is contained in:
14
src/main.rs
14
src/main.rs
@@ -1,28 +1,16 @@
|
||||
mod downloader;
|
||||
mod state;
|
||||
mod streamer;
|
||||
|
||||
use axum::{Router, extract::State, routing::get};
|
||||
use axum::{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()).await;
|
||||
|
||||
"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:3029");
|
||||
|
Reference in New Issue
Block a user