1use rocket::form::Form;
2use rocket::fs::NamedFile;
3use rocket::post;
4use tempdir::TempDir;
5use texc_config::Config;
6
7
8#[post("/", data = "<input>")]
11pub async fn texc_post(input: Form<Config>) -> Option<NamedFile> {
12 let temp_dir = TempDir::new("texc_temp").unwrap();
13 let temp_path = temp_dir.path().join(format!("{}.zip", &input.project_name));
14 if input.only_files.unwrap() {
15 input.zip_files(temp_dir.path().to_owned()).await.unwrap();
16 } else {
17 input.zip_proj(temp_dir.path().to_owned()).await.unwrap();
18 }
19 NamedFile::open(temp_path).await.ok()
20}