Skip to content

Commit 9538573

Browse files
committed
支持自定义端口
1 parent 0e908ad commit 9538573

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package main
22

33
import (
44
"FileServerFiber/logic"
5+
"flag"
6+
"fmt"
57

68
"github.com/gofiber/fiber/v2"
79
"github.com/gofiber/fiber/v2/middleware/recover"
@@ -10,6 +12,8 @@ import (
1012

1113
func main() {
1214

15+
port := flag.Int("p", 4000, "启动端口")
16+
flag.Parse()
1317
engine := html.New("./tmpl", ".html")
1418

1519
app := fiber.New(fiber.Config{
@@ -22,6 +26,6 @@ func main() {
2226

2327
app.Get("/*", logic.Tmpl)
2428

25-
app.Listen(":9512")
29+
app.Listen(fmt.Sprintf(":%d", *port))
2630

2731
}

0 commit comments

Comments
 (0)