mirror of https://github.com/rwf2/Rocket.git
24 lines
510 B
Rust
24 lines
510 B
Rust
#![feature(plugin)]
|
|
#![plugin(rocket_codegen)]
|
|
|
|
extern crate rocket;
|
|
|
|
use std::io;
|
|
|
|
use rocket::Data;
|
|
use rocket::response::content::Plain;
|
|
|
|
#[post("/upload", format = "text/plain", data = "<data>")]
|
|
fn upload(data: Data) -> io::Result<Plain<String>> {
|
|
data.stream_to_file("/tmp/upload.txt").map(|n| Plain(n.to_string()))
|
|
}
|
|
|
|
#[get("/")]
|
|
fn index() -> &'static str {
|
|
"Upload your text files by POSTing them to /upload."
|
|
}
|
|
|
|
fn main() {
|
|
rocket::ignite().mount("/", routes![index, upload]).launch();
|
|
}
|