code auth added

This commit is contained in:
partisan 2024-08-08 13:35:50 +02:00
parent f6576a9134
commit 9f655ba8c0
5 changed files with 127 additions and 145 deletions

30
main.go
View file

@ -122,20 +122,19 @@ func parsePageParameter(pageStr string) int {
}
func runServer() {
// 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")
// })
// http.HandleFunc("/opensearch.xml", func(w http.ResponseWriter, r *http.Request) {
// w.Header().Set("Content-Type", "application/opensearchdescription+xml")
// http.ServeFile(w, r, "static/opensearch.xml")
// })
// initializeTorrentSites()
http.HandleFunc("/node", handleNodeRequest) // Handle node requests
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("/node", handleNodeRequest)
http.HandleFunc("/settings", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "templates/settings.html")
})
http.HandleFunc("/opensearch.xml", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/opensearchdescription+xml")
http.ServeFile(w, r, "static/opensearch.xml")
})
initializeTorrentSites()
config := loadConfig()
generateOpenSearchXML(config)
@ -143,9 +142,6 @@ func runServer() {
fmt.Printf("Server is listening on http://localhost:%d\n", config.Port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", config.Port), nil))
// Start node communication client
go startNodeClient(peers)
// Start automatic update checker
go checkForUpdates()
}