add a redirect query for no javascript

This commit is contained in:
2026-11-10 14:46:28 -05:00
parent 121fa30a04
commit 6181bd2e4d
2 changed files with 12 additions and 2 deletions
+10
View File
@@ -62,6 +62,10 @@ func uploadHandler(db *gorm.DB, cfg Config) http.HandlerFunc {
if r.URL.Query().Get("idlength") == "short" {
idLength = 10
}
redirect := false
if r.URL.Query().Get("redirect") == "true" {
redirect = true
}
var input UploadInput
switch mediaType {
@@ -202,6 +206,12 @@ func uploadHandler(db *gorm.DB, cfg Config) http.HandlerFunc {
return
}
saved = true
if redirect {
http.Redirect(w, r, "/"+id, http.StatusSeeOther)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
if err := json.NewEncoder(w).Encode(UploadResponse{