mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-23 17:52:36 -04:00
Migrate to actix
This commit is contained in:
parent
d106988fd7
commit
5543bc4c9d
@ -1,5 +1,4 @@
|
||||
{pkgs ? import <nixpkgs> {}}: let
|
||||
pwd = ./.;
|
||||
venvDir = "./scanner/.venv";
|
||||
pythonPkgs = ./scanner/requirements.txt;
|
||||
in
|
||||
@ -26,7 +25,7 @@ in
|
||||
# Install python modules
|
||||
SOURCE_DATE_EPOCH=$(date +%s)
|
||||
if [ ! -d "${venvDir}" ]; then
|
||||
${pkgs.python3}/bin/python3 -m venv ${pwd}/${venvDir}
|
||||
${pkgs.python3}/bin/python3 -m venv ${toString ./.}/${venvDir}
|
||||
source ${venvDir}/bin/activate
|
||||
export PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
pip install -r ${pythonPkgs} >&2
|
||||
|
1
transcoder/.dockerignore
Normal file
1
transcoder/.dockerignore
Normal file
@ -0,0 +1 @@
|
||||
target/
|
1230
transcoder/Cargo.lock
generated
1230
transcoder/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,4 +4,5 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
rocket = "=0.5.0-rc.3"
|
||||
actix-web = "4"
|
||||
actix-files = "0.6.2"
|
||||
|
@ -14,7 +14,5 @@ FROM debian:bullseye-slim
|
||||
#RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder /usr/local/cargo/bin/transcoder ./transcoder
|
||||
|
||||
ENV ROCKET_ADDRESS=0.0.0.0
|
||||
ENV ROCKET_PORT=7666
|
||||
EXPOSE 7666
|
||||
CMD ./transcoder
|
||||
|
@ -8,7 +8,5 @@ COPY Cargo.toml Cargo.lock ./
|
||||
RUN cargo build
|
||||
RUN rm src/lib.rs
|
||||
|
||||
ENV ROCKET_ADDRESS=0.0.0.0
|
||||
ENV ROCKET_PORT=7666
|
||||
EXPOSE 7666
|
||||
CMD cargo watch -x run
|
||||
|
@ -1,12 +1,20 @@
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
use actix_files::NamedFile;
|
||||
use actix_web::{get, web, App, HttpServer, Result};
|
||||
mod paths;
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> &'static str {
|
||||
"Hello, world!"
|
||||
#[get("/movie/direct/{slug}")]
|
||||
async fn index(query: web::Path<String>) -> Result<NamedFile> {
|
||||
let slug = query.into_inner();
|
||||
let path = paths::get_movie_path(slug);
|
||||
|
||||
Ok(NamedFile::open_async(path).await?)
|
||||
// .map(|f| (infer_content_type(f), f))
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build().mount("/", routes![index])
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| App::new().service(index))
|
||||
.bind(("0.0.0.0", 7666))?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
4
transcoder/src/paths.rs
Normal file
4
transcoder/src/paths.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub fn get_movie_path(_slug: String) -> String {
|
||||
// TODO: Implement this method to fetch the path from the API.
|
||||
String::from("/video/test.mkv")
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user