mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
New: Flag for port
This commit is contained in:
parent
29460a6c26
commit
d3e04ef2ed
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func serve() {
|
func serve(port string) {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
router.LoadHTMLGlob("templates/*")
|
router.LoadHTMLGlob("templates/*")
|
||||||
router.Use(static.Serve("/static/", static.LocalFile("./static", true)))
|
router.Use(static.Serve("/static/", static.LocalFile("./static", true)))
|
||||||
@ -28,7 +28,7 @@ func serve() {
|
|||||||
router.POST("/lock", handleLock)
|
router.POST("/lock", handleLock)
|
||||||
router.POST("/encrypt", handleEncrypt)
|
router.POST("/encrypt", handleEncrypt)
|
||||||
|
|
||||||
router.Run(":8050")
|
router.Run(":" + port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handlePageRequest(c *gin.Context) {
|
func handlePageRequest(c *gin.Context) {
|
||||||
|
7
main.go
7
main.go
@ -32,6 +32,11 @@ func main() {
|
|||||||
Value: "",
|
Value: "",
|
||||||
Usage: "data folder for migrating",
|
Usage: "data folder for migrating",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "port,p",
|
||||||
|
Value: "8050",
|
||||||
|
Usage: "port to use",
|
||||||
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "debug, d",
|
Name: "debug, d",
|
||||||
Usage: "turn on debugging",
|
Usage: "turn on debugging",
|
||||||
@ -45,7 +50,7 @@ func main() {
|
|||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
pathToData = c.GlobalString("data")
|
pathToData = c.GlobalString("data")
|
||||||
os.MkdirAll(pathToData, 0755)
|
os.MkdirAll(pathToData, 0755)
|
||||||
serve()
|
serve(c.GlobalString("port"))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user