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