index: Add select for choosing languages when pasting
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user