mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Migrate to actix
This commit is contained in:
parent
d106988fd7
commit
5543bc4c9d
@ -1,5 +1,4 @@
|
|||||||
{pkgs ? import <nixpkgs> {}}: let
|
{pkgs ? import <nixpkgs> {}}: let
|
||||||
pwd = ./.;
|
|
||||||
venvDir = "./scanner/.venv";
|
venvDir = "./scanner/.venv";
|
||||||
pythonPkgs = ./scanner/requirements.txt;
|
pythonPkgs = ./scanner/requirements.txt;
|
||||||
in
|
in
|
||||||
@ -26,7 +25,7 @@ in
|
|||||||
# Install python modules
|
# Install python modules
|
||||||
SOURCE_DATE_EPOCH=$(date +%s)
|
SOURCE_DATE_EPOCH=$(date +%s)
|
||||||
if [ ! -d "${venvDir}" ]; then
|
if [ ! -d "${venvDir}" ]; then
|
||||||
${pkgs.python3}/bin/python3 -m venv ${pwd}/${venvDir}
|
${pkgs.python3}/bin/python3 -m venv ${toString ./.}/${venvDir}
|
||||||
source ${venvDir}/bin/activate
|
source ${venvDir}/bin/activate
|
||||||
export PIP_DISABLE_PIP_VERSION_CHECK=1
|
export PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||||
pip install -r ${pythonPkgs} >&2
|
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"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[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/*
|
#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
|
COPY --from=builder /usr/local/cargo/bin/transcoder ./transcoder
|
||||||
|
|
||||||
ENV ROCKET_ADDRESS=0.0.0.0
|
|
||||||
ENV ROCKET_PORT=7666
|
|
||||||
EXPOSE 7666
|
EXPOSE 7666
|
||||||
CMD ./transcoder
|
CMD ./transcoder
|
||||||
|
@ -8,7 +8,5 @@ COPY Cargo.toml Cargo.lock ./
|
|||||||
RUN cargo build
|
RUN cargo build
|
||||||
RUN rm src/lib.rs
|
RUN rm src/lib.rs
|
||||||
|
|
||||||
ENV ROCKET_ADDRESS=0.0.0.0
|
|
||||||
ENV ROCKET_PORT=7666
|
|
||||||
EXPOSE 7666
|
EXPOSE 7666
|
||||||
CMD cargo watch -x run
|
CMD cargo watch -x run
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
#[macro_use]
|
use actix_files::NamedFile;
|
||||||
extern crate rocket;
|
use actix_web::{get, web, App, HttpServer, Result};
|
||||||
|
mod paths;
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/movie/direct/{slug}")]
|
||||||
fn index() -> &'static str {
|
async fn index(query: web::Path<String>) -> Result<NamedFile> {
|
||||||
"Hello, world!"
|
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]
|
#[actix_web::main]
|
||||||
fn rocket() -> _ {
|
async fn main() -> std::io::Result<()> {
|
||||||
rocket::build().mount("/", routes![index])
|
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