add simple settings template, cleanup

This commit is contained in:
partisan 2024-04-15 08:35:17 +02:00
parent d6edd14f16
commit 1efca320c8
10 changed files with 192 additions and 154 deletions

14
main.go
View file

@ -63,18 +63,14 @@ var languageOptions = []LanguageOption{
{Code: "lang_vi", Name: "Tiếng Việt (Vietnamese)"},
}
// var funcs = template.FuncMap{
// "title": func(s string) string { return strings.Title(s) },
// "url_for": func(filename string) string { return "/" + filename },
// }
// var templates = template.Must(template.New("").Funcs(funcs).ParseFiles("templates/results.html"))
func main() {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
http.HandleFunc("/", handleSearch)
http.HandleFunc("/search", handleSearch)
http.HandleFunc("/img_proxy", handleImageProxy)
http.HandleFunc("/settings", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "templates/settings.html")
})
fmt.Println("Server is listening on http://localhost:5000")
log.Fatal(http.ListenAndServe(":5000", nil))
}
@ -102,7 +98,7 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
}
if query == "" {
http.ServeFile(w, r, "static/search.html")
http.ServeFile(w, r, "templates/search.html")
return
}
@ -114,6 +110,6 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
case "video":
videoSearchEndpointHandler(w, r)
default:
http.ServeFile(w, r, "static/search.html")
http.ServeFile(w, r, "templates/search.html")
}
}