mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Fixed folders for static
Former-commit-id: 4a38971bd37fe3e363d63f35c23f0600e19ca7f3 [formerly 069f5528afe5d6770c59721e5dca25a2a58ac022] [formerly fc96b8c5a409b606b5c2cd783a6f46aeb005aa2d [formerly 0a182f98cb3cecde4c51f4aa7ff50ed3e48c85cf [formerlyfe06f599bd
]]] Former-commit-id: 06bfeeaf5f17c68c24d207e7cc71113d2412eca8 [formerly 5f7834e441f5b3c7c56892eae626d13b8c4e6f2b] Former-commit-id: 1b9223c05d4b232960d1abbcde01e02514cdb020 Former-commit-id:659c15b0bb
This commit is contained in:
parent
a164d124d9
commit
537aa3c034
4
main.go
4
main.go
@ -26,6 +26,7 @@ var RuntimeArgs struct {
|
|||||||
DatabaseLocation string
|
DatabaseLocation string
|
||||||
ServerCRT string
|
ServerCRT string
|
||||||
ServerKey string
|
ServerKey string
|
||||||
|
SourcePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -51,6 +52,7 @@ Options:`)
|
|||||||
if RuntimeArgs.ExternalIP == "" {
|
if RuntimeArgs.ExternalIP == "" {
|
||||||
log.Fatal("You need to specify the external IP address")
|
log.Fatal("You need to specify the external IP address")
|
||||||
}
|
}
|
||||||
|
RuntimeArgs.SourcePath = path.Dir(executableFile)
|
||||||
Open(RuntimeArgs.DatabaseLocation)
|
Open(RuntimeArgs.DatabaseLocation)
|
||||||
defer Close()
|
defer Close()
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ Options:`)
|
|||||||
//rebuildTexts(q)
|
//rebuildTexts(q)
|
||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.LoadHTMLGlob(path.Join(path.Dir(executableFile), "templates/*"))
|
r.LoadHTMLGlob(path.Join(RuntimeArgs.SourcePath, "templates/*"))
|
||||||
r.GET("/", newNote)
|
r.GET("/", newNote)
|
||||||
r.GET("/:title", editNote)
|
r.GET("/:title", editNote)
|
||||||
r.GET("/:title/*option", everythingElse)
|
r.GET("/:title/*option", everythingElse)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -56,7 +57,7 @@ func everythingElse(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func serveStaticFile(c *gin.Context, option string) {
|
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 {
|
if err != nil {
|
||||||
c.AbortWithStatus(404)
|
c.AbortWithStatus(404)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user