From fe06f599bdcdc4685ba3d3d056676f67c79ee8a8 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Mon, 8 Feb 2016 10:03:00 -0500 Subject: [PATCH] Fixed folders for static --- main.go | 4 +++- routes.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 37c84ea..6cc3df2 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ var RuntimeArgs struct { DatabaseLocation string ServerCRT string ServerKey string + SourcePath string } func main() { @@ -51,6 +52,7 @@ Options:`) if RuntimeArgs.ExternalIP == "" { log.Fatal("You need to specify the external IP address") } + RuntimeArgs.SourcePath = path.Dir(executableFile) Open(RuntimeArgs.DatabaseLocation) defer Close() @@ -63,7 +65,7 @@ Options:`) //rebuildTexts(q) r := gin.Default() - r.LoadHTMLGlob(path.Join(path.Dir(executableFile), "templates/*")) + r.LoadHTMLGlob(path.Join(RuntimeArgs.SourcePath, "templates/*")) r.GET("/", newNote) r.GET("/:title", editNote) r.GET("/:title/*option", everythingElse) diff --git a/routes.go b/routes.go index 9456278..782f392 100644 --- a/routes.go +++ b/routes.go @@ -4,6 +4,7 @@ import ( "html/template" "io/ioutil" "net/http" + "path" "regexp" "strconv" "strings" @@ -56,7 +57,7 @@ func everythingElse(c *gin.Context) { } func serveStaticFile(c *gin.Context, option string) { - staticFile, err := ioutil.ReadFile("./static" + option) + staticFile, err := ioutil.ReadFile(path.Join(RuntimeArgs.SourcePath, "static") + option) if err != nil { c.AbortWithStatus(404) } else {