mirror of
https://github.com/Unkn0wnCat/gohangar.git
synced 2025-04-28 09:36:26 +02:00
Add port argument
This commit is contained in:
parent
9a38e7d0cb
commit
d7528a60b7
1 changed files with 16 additions and 1 deletions
17
main.go
17
main.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/Unkn0wnCat/gohangar/hangar"
|
"github.com/Unkn0wnCat/gohangar/hangar"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
@ -57,6 +58,17 @@ func main() {
|
||||||
Value: "GoHangar",
|
Value: "GoHangar",
|
||||||
Usage: "App name displayed in the footer",
|
Usage: "App name displayed in the footer",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "port",
|
||||||
|
Aliases: []string{"p"},
|
||||||
|
Value: "8123",
|
||||||
|
Usage: "Port to listen on",
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "address",
|
||||||
|
Value: "0.0.0.0",
|
||||||
|
Usage: "Address to listen on",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(cCtx *cli.Context) error {
|
Action: func(cCtx *cli.Context) error {
|
||||||
base := os.DirFS(cCtx.String("dir"))
|
base := os.DirFS(cCtx.String("dir"))
|
||||||
|
@ -72,7 +84,10 @@ func main() {
|
||||||
myHangar.Banner = cCtx.String("header")
|
myHangar.Banner = cCtx.String("header")
|
||||||
myHangar.SiteName = cCtx.String("name")
|
myHangar.SiteName = cCtx.String("name")
|
||||||
|
|
||||||
err = http.ListenAndServe("localhost:8123", myHangar)
|
listen := fmt.Sprintf("%s:%s", cCtx.String("address"), cCtx.String("port"))
|
||||||
|
|
||||||
|
log.Printf("Listening on %s...", listen)
|
||||||
|
err = http.ListenAndServe(listen, myHangar)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue