goroutine

main
sandyx 1 year ago
parent a5a3fdb792
commit b6ed586a2d

@ -89,6 +89,45 @@ func main() {
log.Fatal(err)
}
for _, e := range entries {
go func() {
new := e.Name()
newImg := strings.TrimSuffix(new, filepath.Ext(new)) + ".png"
if filepath.Ext(new) != ".pdf" {
return
}
dir, _ := filepath.Abs(*directory)
cmd := exec.Command("./tncmd.sh", filepath.Join(dir, e.Name()))
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")
file, err := os.Open(*directory +"/"+ newImg)
if err != nil {
http.Error(w, "File not found.", http.StatusNotFound)
return
}
defer file.Close()
_, err = io.Copy(w, file)
if err != nil {
http.Error(w, "Error sending file.", http.StatusInternalServerError)
return
}
})
}
}()
}
for _, e := range entries {
new := e.Name()
newImg := strings.TrimSuffix(new, filepath.Ext(new)) + ".png"
@ -97,34 +136,6 @@ func main() {
continue
}
dir, _ := filepath.Abs(*directory)
cmd := exec.Command("./tncmd.sh", filepath.Join(dir, e.Name()))
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")
file, err := os.Open(*directory +"/"+ newImg)
if err != nil {
http.Error(w, "File not found.", http.StatusNotFound)
return
}
defer file.Close()
_, err = io.Copy(w, file)
if err != nil {
http.Error(w, "Error sending file.", http.StatusInternalServerError)
return
}
})
}
//if new == "style.css" { continue }
http.HandleFunc("/" + url.QueryEscape(new), func(w http.ResponseWriter, r *http.Request) {

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

Loading…
Cancel
Save