Added mod time to files

This commit is contained in:
Caleb Gardner
2024-08-23 18:03:25 -05:00
parent 1dc937fcaf
commit 42064fd64c
+4 -2
View File
@@ -6,9 +6,10 @@ import (
"net/http"
"os"
"path/filepath"
"time"
)
const fileElement = "<p><a href='https://darkstorm.tech%v'>%v</a></p>"
const fileElement = "<p><a href='https://darkstorm.tech%v'>%v</a><div style='float:right;'>%v</div></p>"
func filesRequest(w http.ResponseWriter, r *http.Request) {
partPath := filepath.Clean(r.URL.Path)
@@ -38,7 +39,8 @@ func filesRequest(w http.ResponseWriter, r *http.Request) {
if f.IsDir() {
continue
}
pageContent += fmt.Sprintf(fileElement, filepath.Join(partPath, f.Name()), f.Name())
inf, _ := f.Info()
pageContent += fmt.Sprintf(fileElement, filepath.Join(partPath, f.Name()), f.Name(), inf.ModTime().Format(time.DateOnly))
}
} else {
http.ServeFile(w, r, path)