31 lines
759 B
Go
31 lines
759 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"reader/pkg/handlers"
|
|
)
|
|
|
|
func main() {
|
|
path := "/home/psa/GoRepository/"
|
|
port := 8080
|
|
|
|
http.HandleFunc("GET /download", handlers.Download) // example request: {"date": "07-03-2025", "start_time": "16-43", "end_time": "16-44"}
|
|
http.HandleFunc("GET /hls", handlers.HLS)
|
|
//http.Handle("/", addHeaders(http.FileServer(http.Dir(path))))
|
|
|
|
log.Println("Starting server on:")
|
|
log.Printf("Serving %s on HTTP port: %d\n", path, port)
|
|
|
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
|
|
|
|
}
|
|
|
|
//func addHeaders(h http.Handler) http.Handler {
|
|
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
// w.Header().Set("Access-Control-Allow-Origin", "*")
|
|
// h.ServeHTTP(w, r)
|
|
// })
|
|
//}
|