Spaces:
Runtime error
Runtime error
Download src/controllers/v1/keyframes/mod.rs from variphx/aic-server: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/variphx/aic-server/resolve/main/src/controllers/v1/keyframes/mod.rs
- Command line
-
hf download hf://spaces/variphx/aic-server/src/controllers/v1/keyframes/mod.rs
-
curl -L -o mod.rs https://huggingface.co/spaces/variphx/aic-server/resolve/main/src/controllers/v1/keyframes/mod.rs
1.05 kB
| use axum::{ | |
| Json, | |
| extract::{Path, State}, | |
| http::StatusCode, | |
| }; | |
| use utoipa_axum::{router::OpenApiRouter, routes}; | |
| use crate::{ | |
| constants::OPENAPI_TAG, | |
| models::{dtos::keyframes::KeyframeDto, states::AppState}, | |
| services::keyframes::KeyframeService, | |
| }; | |
| pub fn router() -> OpenApiRouter<AppState> { | |
| OpenApiRouter::new().routes(routes!(find_by_id)) | |
| } | |
| async fn find_by_id( | |
| Path(id): Path<i64>, | |
| State(state): State<AppState>, | |
| ) -> Result<Json<KeyframeDto>, StatusCode> { | |
| let service = KeyframeService::from(&state); | |
| match service.find_by_id(id).await { | |
| Ok(result) => result.map(Json).ok_or(StatusCode::NOT_FOUND), | |
| Err(e) => { | |
| tracing::debug!("{:?}", e); | |
| Err(StatusCode::INTERNAL_SERVER_ERROR) | |
| } | |
| } | |
| } | |