@@ -162,14 +162,28 @@ func isAudio(mime string) bool {
162162}
163163
164164func homePage (c * gin.Context ) {
165+ admin := c .Query ("admin" )
165166 files , err := database .ListFiles (10 , 1 )
166167 if err != nil {
167168 log .Printf ("Error listing files: %v" , err )
168169 c .String (http .StatusInternalServerError , "Error retrieving files" )
169170 return
170171 }
171172 c .HTML (http .StatusOK , "index.tmpl" , gin.H {
172- "files" : files })
173+ "files" : files ,
174+ "admin" : admin == "admin" })
175+ }
176+
177+ func delete (c * gin.Context ) {
178+ name := c .Query ("name" )
179+
180+ err := database .DeleteFile (name )
181+ if err != nil {
182+ c .String (http .StatusInternalServerError , "Error deleting file" )
183+ return
184+ }
185+
186+ c .String (http .StatusOK , "File deleted successfully" )
173187}
174188
175189func main () {
@@ -209,6 +223,7 @@ func main() {
209223 router .GET ("/" , homePage )
210224 router .GET ("/hash" , getHash )
211225 router .POST ("/upload" , postFile )
226+ router .GET ("/delete/" , delete )
212227 router .Static ("/files" , "./files" )
213228 router .GET ("/thumbs/:filename" , getThumbnail )
214229 router .StaticFile ("favicon.ico" , "./favicon.ico" )
0 commit comments