server port added

This commit is contained in:
Andreas Schröpfer
2021-03-03 14:51:12 +01:00
parent 664d7750a6
commit 8bb2be248d

View File

@@ -3,6 +3,7 @@ package main
import (
"bytes"
_ "embed"
"flag"
"fmt"
"io"
"log"
@@ -15,6 +16,10 @@ import (
//go:embed files/upload.htm
var homepage []byte
var (
flagPort = flag.String("p", ":2727", "port for the http-server")
)
func main() {
run()
}
@@ -22,17 +27,16 @@ func main() {
func run() {
mux := http.NewServeMux()
mux.HandleFunc("/convert/", handleConvert)
mux.HandleFunc("/test/", handleRoot)
mux.HandleFunc("/", handleRoot)
s := &http.Server{
Addr: ":2727",
Addr: *flagPort,
Handler: mux,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
fmt.Println("starting server at:")
fmt.Println("http://localhost:2727/")
fmt.Printf("http://localhost:%s/", *flagPort)
log.Fatal(s.ListenAndServe())
}