2016-10-12 07:14:42 +00:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(rocket_codegen)]
|
|
|
|
|
|
|
|
extern crate rocket;
|
|
|
|
|
2017-05-25 05:56:52 +00:00
|
|
|
#[cfg(test)] mod tests;
|
2016-10-13 02:08:19 +00:00
|
|
|
|
2017-05-25 05:56:52 +00:00
|
|
|
use std::io;
|
2016-10-25 11:24:07 +00:00
|
|
|
use rocket::Data;
|
2016-10-12 07:14:42 +00:00
|
|
|
|
2016-10-12 23:48:32 +00:00
|
|
|
#[post("/upload", format = "text/plain", data = "<data>")]
|
2017-05-25 05:56:52 +00:00
|
|
|
fn upload(data: Data) -> io::Result<String> {
|
|
|
|
data.stream_to_file("/tmp/upload.txt").map(|n| n.to_string())
|
2016-10-12 07:14:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
fn index() -> &'static str {
|
|
|
|
"Upload your text files by POSTing them to /upload."
|
|
|
|
}
|
|
|
|
|
2017-05-25 05:56:52 +00:00
|
|
|
fn rocket() -> rocket::Rocket {
|
|
|
|
rocket::ignite().mount("/", routes![index, upload])
|
|
|
|
}
|
|
|
|
|
2016-10-12 07:14:42 +00:00
|
|
|
fn main() {
|
2017-05-25 05:56:52 +00:00
|
|
|
rocket().launch();
|
2016-10-12 07:14:42 +00:00
|
|
|
}
|