mirror of
https://github.com/ivanch/tcc.git
synced 2025-08-25 23:31:49 +00:00
add json route
This commit is contained in:
@@ -5,7 +5,7 @@ use magick_rust::MagickWand;
|
||||
|
||||
#[get("/status/ok")]
|
||||
async fn hello() -> impl Responder {
|
||||
HttpResponse::Ok().body("{\"status\": 200}")
|
||||
HttpResponse::Ok()
|
||||
}
|
||||
|
||||
async fn static_serve(req: HttpRequest) -> Result<NamedFile> {
|
||||
@@ -29,6 +29,17 @@ async fn simulation_harmonic_progression(req: HttpRequest) -> impl Responder {
|
||||
HttpResponse::Ok().body(format!("{}", sum))
|
||||
}
|
||||
|
||||
#[get("/simulation/json")]
|
||||
async fn simulation_json() -> impl Responder {
|
||||
// body = {"message": "Hello World"}
|
||||
let body = serde_json::json!({
|
||||
"message": "Hello World!"
|
||||
});
|
||||
|
||||
HttpResponse::Ok()
|
||||
.json(body)
|
||||
}
|
||||
|
||||
#[get("/image/load-small-image")]
|
||||
async fn load_small_image() -> Result<NamedFile> {
|
||||
let real_path = "static/small-image.png";
|
||||
@@ -89,6 +100,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.service(save_big_image)
|
||||
.service(blur_image)
|
||||
.service(simulation_harmonic_progression)
|
||||
.service(simulation_json)
|
||||
.app_data(web::PayloadConfig::new(1024 * 1024 * 1024))
|
||||
})
|
||||
.bind(("0.0.0.0", 5000))?
|
||||
|
Reference in New Issue
Block a user