index: Add select for choosing languages when pasting

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain
2021-07-13 01:38:22 +05:30
parent fbc92b669d
commit 1175a57539
2 changed files with 125 additions and 40 deletions

View File

@@ -7,6 +7,7 @@ use crate::models::paste_id::PasteId;
#[derive(FromForm)]
pub struct PasteIdForm {
val: String,
ext: String,
}
#[post("/submit", data = "<paste>")]
@@ -14,9 +15,10 @@ pub async fn submit(paste: Form<PasteIdForm>) -> Redirect {
let id = PasteId::new(6);
let filename = format!("upload/{id}", id = id);
let content = paste.into_inner().val;
let content = &paste.val;
let ext = &paste.ext;
fs::write(&filename, content).expect("Unable to write to the file");
Redirect::to(format!("/p/{id}", id = id))
}
Redirect::to(format!("/p/{id}.{ext}", id = id, ext = ext))
}