goroutine

main
sandyx 1 year ago
parent a5a3fdb792
commit b6ed586a2d

@ -90,39 +90,50 @@ func main() {
} }
for _, e := range entries { for _, e := range entries {
new := e.Name() go func() {
newImg := strings.TrimSuffix(new, filepath.Ext(new)) + ".png" new := e.Name()
newImg := strings.TrimSuffix(new, filepath.Ext(new)) + ".png"
if filepath.Ext(new) != ".pdf" { if filepath.Ext(new) != ".pdf" {
continue return
} }
dir, _ := filepath.Abs(*directory)
dir, _ := filepath.Abs(*directory) cmd := exec.Command("./tncmd.sh", filepath.Join(dir, e.Name()))
cmd := exec.Command("./tncmd.sh", filepath.Join(dir, e.Name())) fmt.Println(cmd)
fmt.Println(cmd) if err := cmd.Run(); err != nil {
log.Println(err)
} else {
fmt.Println("Created thumbnail for: " + new)
http.HandleFunc("/" + newImg, func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "img/png")
if err := cmd.Run(); err != nil { file, err := os.Open(*directory +"/"+ newImg)
log.Println(err) if err != nil {
} else { http.Error(w, "File not found.", http.StatusNotFound)
fmt.Println("Created thumbnail for: " + new) return
http.HandleFunc("/" + newImg, func(w http.ResponseWriter, r *http.Request) { }
w.Header().Set("Content-Type", "img/png") defer file.Close()
file, err := os.Open(*directory +"/"+ newImg) _, err = io.Copy(w, file)
if err != nil { if err != nil {
http.Error(w, "File not found.", http.StatusNotFound) http.Error(w, "Error sending file.", http.StatusInternalServerError)
return return
} }
defer file.Close() })
}
}()
}
for _, e := range entries {
new := e.Name()
newImg := strings.TrimSuffix(new, filepath.Ext(new)) + ".png"
_, err = io.Copy(w, file) if filepath.Ext(new) != ".pdf" {
if err != nil { continue
http.Error(w, "Error sending file.", http.StatusInternalServerError)
return
}
})
} }
//if new == "style.css" { continue } //if new == "style.css" { continue }

@ -1,19 +1,20 @@
.grid-container { .grid-container {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
font-size: 4vh; //font-size: 4vh;
//width: 100%; //width: 100%;
display: grid; display: grid;
grid-template-columns: repeat(100, 1fr); grid-template-columns: repeat(3, 1fr);
grid-auto-rows: minmax(100px, auto); grid-auto-rows: minmax(100%, auto);
margin-left: 30%; margin-left: 30%;
margin-right: 30%;
} }
.grid-item { .grid-item {
padding: 10px; padding: 5px;
background: green; background: green;
border-radius: 20px; border-radius: 0px;
border: 1px solid white; border: 1px solid white;
text-align: left; text-align: center;
} }
a { a {

Loading…
Cancel
Save