Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Jan 21, 2024
1 parent f05b21e commit 332f5d5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ mod config;
mod ffmpeg;
mod utils;

use axum::{response::Html, routing::get, Router};
use axum::{
response::{Html, IntoResponse},
routing::get,
Router,
};
use clap::Parser;
use metrics_exporter_prometheus::PrometheusBuilder;
use std::{fs, net::SocketAddr, path::PathBuf, time::Duration};
Expand Down Expand Up @@ -85,9 +89,18 @@ async fn main() {

// Configure HTTP server routes
let frame_image = SharedImageData::default();
let frame_image_2 = frame_image.clone();
let app = Router::new()
.route("/player", get(Html(include_str!("player.html"))))
// .nest_service("/frame.jpg", ServeFile::new(frame_file))
.route(
"/frame.jpg",
get(move || async move {
match frame_image_2.lock().unwrap().as_ref() {
Some(image) => image.clone().into_response(),
None => axum::http::StatusCode::NOT_FOUND.into_response(),
}
}),
)
.nest_service("/", ServeDir::new(config.video_directory.clone()));

// Start HTTP server
Expand Down

0 comments on commit 332f5d5

Please sign in to comment.