Revert "feat(filehole): serve indexes from applet dir"

This reverts commit 9c41526bc6.
This commit is contained in:
hgc 2023-05-30 04:41:37 +00:00
parent 9c41526bc6
commit be16d6ff47
2 changed files with 6 additions and 16 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
/filehole.db
/filehole
/data/
/applet/

21
main.go
View File

@ -1,10 +1,8 @@
package main
import (
"io/fs"
"path"
"crypto/rand"
"embed"
_ "embed"
"html"
"io"
"net/http"
@ -143,17 +141,8 @@ func ExpiryDoer() {
}
}
//go:embed applet/**
var indexApplet embed.FS
// myFS implements fs.FS
type myFS struct {
content embed.FS
}
func (c myFS) Open(name string) (fs.File, error) {
return c.content.Open(path.Join("applet", name))
}
//go:embed index.html
var indexPage []byte
func main() {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
@ -220,7 +209,9 @@ func main() {
// Serve files from data dir statically
r.PathPrefix("/u/").Handler(http.StripPrefix("/u/", NoDirectoryList(http.FileServer(http.Dir(viper.GetString("filedir"))))))
r.PathPrefix("/").Handler(http.FileServer(http.FS(myFS{indexApplet}))).Methods("GET")
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write(indexPage)
}).Methods("GET")
r.HandleFunc("/", UploadHandler).Methods("POST")
http.Handle("/", r)