2019-11-19 05:51:48 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"net/http"
|
|
|
|
|
2025-04-03 12:40:41 +00:00
|
|
|
"ascii-live/handlers"
|
2019-11-19 05:51:48 +00:00
|
|
|
|
|
|
|
"github.com/golang/glog"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Server.
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
// Don't write to /tmp - doesn't work in docker scratch
|
|
|
|
flag.Set("logtostderr", "true")
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
2025-03-27 12:45:43 +00:00
|
|
|
r.HandleFunc("/ascii-live/list", handlers.ListHandler).Methods("GET")
|
|
|
|
r.HandleFunc("/ascii-live/{frameSource}", handlers.Handler).Methods("GET")
|
|
|
|
r.NotFoundHandler = http.HandlerFunc(handlers.NotFoundHandler)
|
2019-11-19 05:51:48 +00:00
|
|
|
|
|
|
|
srv := &http.Server{
|
|
|
|
Handler: r,
|
|
|
|
Addr: ":8080",
|
|
|
|
// Set unlimited read/write timeouts
|
|
|
|
ReadTimeout: 0,
|
|
|
|
WriteTimeout: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
glog.Infof("Serving...")
|
|
|
|
glog.Fatal(srv.ListenAndServe())
|
|
|
|
}
|