Not quite there, have to work out the correct return types for the POST method.
This commit is contained in:
parent
7aa9a630be
commit
a11745e952
3 changed files with 29 additions and 0 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -8,3 +8,11 @@ Cargo.lock
|
|||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
|
||||
#Added by cargo
|
||||
#
|
||||
#already existing elements are commented out
|
||||
|
||||
/target
|
||||
#**/*.rs.bk
|
||||
|
|
|
@ -6,3 +6,6 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
rocket="0.4.*"
|
||||
image="*"
|
||||
tempfile="3.*"
|
||||
|
||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -2,6 +2,16 @@
|
|||
|
||||
#[macro_use] extern crate rocket;
|
||||
|
||||
//extern crate rand;
|
||||
|
||||
extern crate image;
|
||||
//extern crate tempfile;
|
||||
|
||||
//use std::io;
|
||||
|
||||
use rocket::Data;
|
||||
use rocket::response::content;
|
||||
|
||||
#[cfg(test)] mod tests;
|
||||
|
||||
#[get("/")]
|
||||
|
@ -19,6 +29,14 @@ fn index() -> &'static str {
|
|||
"
|
||||
}
|
||||
|
||||
#[post("/", data = "<incoming_image>")]
|
||||
fn desteg(incoming_image: Data) -> image::DynamicImage {
|
||||
|
||||
let image_buffer = image::load_from_memory(incoming_image.peek()).unwrap();
|
||||
|
||||
image_buffer
|
||||
}
|
||||
|
||||
fn rocket() -> rocket::Rocket {
|
||||
let my_rocket = rocket::ignite().mount("/", routes![index]);
|
||||
my_rocket
|
||||
|
|
Loading…
Reference in a new issue