feat: ✨ stream from original backend
chore: 🙈 audios
This commit is contained in:
parent
1992354aed
commit
5aafa9befd
4 changed files with 14 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,6 +5,7 @@ target/
|
||||||
.vscode/
|
.vscode/
|
||||||
dist/
|
dist/
|
||||||
certificates/
|
certificates/
|
||||||
|
audios/
|
||||||
|
|
||||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
|
|
|
@ -12,4 +12,6 @@ rand = "0.8.5"
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
serde_json = "1.0.114"
|
serde_json = "1.0.114"
|
||||||
tokio = { version = "1.36.0", features = ["full"] }
|
tokio = { version = "1.36.0", features = ["full"] }
|
||||||
|
#tokio-stream = { version = "0.1.15", features = ["full"] }
|
||||||
|
tokio-util = { version = "0.7.10", features = ["full"] }
|
||||||
tower-http = { version = "0.5.2", features = ["full"] }
|
tower-http = { version = "0.5.2", features = ["full"] }
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use crate::{AppState, ServerStatus, CoinStatus};
|
use crate::{AppState, ServerStatus, CoinStatus};
|
||||||
use axum::{extract::State, http::StatusCode, response::IntoResponse, routing::get, Json, Router};
|
use axum::{body::Body, extract::State, http::StatusCode, response::IntoResponse, routing::get, Json, Router};
|
||||||
|
use tokio::fs::File;
|
||||||
|
use tokio_util::io::ReaderStream;
|
||||||
use tower_http::cors::CorsLayer;
|
use tower_http::cors::CorsLayer;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
|
||||||
|
@ -7,6 +9,7 @@ pub async fn routing(State(state): State<AppState>) -> Router {
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/", get(alive))
|
.route("/", get(alive))
|
||||||
.route("/coin", get(flip_coin))
|
.route("/coin", get(flip_coin))
|
||||||
|
.route("/stream", get(stream))
|
||||||
.layer(CorsLayer::permissive())
|
.layer(CorsLayer::permissive())
|
||||||
.with_state(state.clone())
|
.with_state(state.clone())
|
||||||
}
|
}
|
||||||
|
@ -32,3 +35,9 @@ async fn flip_coin() -> impl IntoResponse {
|
||||||
println!("{}", coin_json);
|
println!("{}", coin_json);
|
||||||
(StatusCode::OK, Json(coin_json))
|
(StatusCode::OK, Json(coin_json))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn stream() -> impl IntoResponse {
|
||||||
|
let file = File::open("audios/audio.mp3").await.unwrap();
|
||||||
|
let stream = ReaderStream::new(file);
|
||||||
|
Body::from_stream(stream)
|
||||||
|
}
|
|
@ -77,7 +77,7 @@ fn app() -> Element {
|
||||||
page_base {}
|
page_base {}
|
||||||
div {
|
div {
|
||||||
audio{
|
audio{
|
||||||
src:"https://radioxide.tahinli.com.tr/audios/music.opus",
|
src:"https://radioxide.tahinli.com.tr:2323/stream",
|
||||||
controls:true,
|
controls:true,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
muted:false,
|
muted:false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue