mirror of
https://github.com/ivanch/tcc.git
synced 2025-08-25 15:21:49 +00:00
adding nginx page & simulation endpoint
This commit is contained in:
@@ -18,7 +18,8 @@ WORKDIR /app
|
||||
|
||||
RUN wget https://files.ivanch.me/api/public/dl/iFuXSNhw/small-image.png && \
|
||||
wget https://files.ivanch.me/api/public/dl/81Bkht5C/big-image.png && \
|
||||
wget https://files.ivanch.me/api/public/dl/nAndfAjK/video.mp4
|
||||
wget https://files.ivanch.me/api/public/dl/nAndfAjK/video.mp4 && \
|
||||
wget https://files.ivanch.me/api/public/dl/RzXwJG7o/nginx.html
|
||||
|
||||
COPY . .
|
||||
|
||||
@@ -27,6 +28,7 @@ RUN cargo build --release && \
|
||||
mv small-image.png ./static && \
|
||||
mv big-image.png ./static && \
|
||||
mv video.mp4 ./static && \
|
||||
mv nginx.html ./static && \
|
||||
ldconfig /usr/local/lib
|
||||
|
||||
ENV LD_LIBRARY_PATH=/usr/local/lib
|
||||
|
@@ -15,6 +15,20 @@ async fn static_serve(req: HttpRequest) -> Result<NamedFile> {
|
||||
Ok(NamedFile::open(real_path)?)
|
||||
}
|
||||
|
||||
#[get("/simulation/harmonic-progression")]
|
||||
async fn simulation_harmonic_progression(req: HttpRequest) -> impl Responder {
|
||||
let query_str = req.query_string();
|
||||
let qs = QString::from(query_str);
|
||||
let radius = qs.get("n").unwrap_or("1").parse::<f64>().unwrap_or(1.0);
|
||||
|
||||
let mut sum = 0.0;
|
||||
for i in 1..=radius as i32 {
|
||||
sum += 1.0 / i as f64;
|
||||
}
|
||||
|
||||
HttpResponse::Ok().body(format!("{}", sum))
|
||||
}
|
||||
|
||||
#[get("/image/load-small-image")]
|
||||
async fn load_small_image() -> Result<NamedFile> {
|
||||
let real_path = "static/small-image.png";
|
||||
@@ -74,6 +88,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.service(load_big_image)
|
||||
.service(save_big_image)
|
||||
.service(blur_image)
|
||||
.service(simulation_harmonic_progression)
|
||||
.app_data(web::PayloadConfig::new(1024 * 1024 * 1024))
|
||||
})
|
||||
.bind(("0.0.0.0", 5000))?
|
||||
|
Reference in New Issue
Block a user