diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -28,7 +28,7 @@ var nonce []byte = nil var db *sql.DB -const baseDocDir string = "docs" +var baseDocDir string = "docs" const NOTFOUND string = "Not found" const UNAUTH string = "Unauthorized" @@ -273,7 +273,7 @@ func index(w http.ResponseWriter, r *http.Request) { file.Name(), humanize(info.Size()), info.ModTime(), - path.Join(baseDocDir, username, file.Name()), + path.Join("/docs/", username, file.Name()), }) } flasherr := consumeFlash(w, r, "error") @@ -635,6 +635,7 @@ func upload(w http.ResponseWriter, r *http.Request) { func main() { p := flag.Int("p", 8080, "the port to bind to") dbPath := flag.String("d", "./db/test.db", "the db to connect to") + docPath := flag.String("f", "docs", "the path of the docs folder") flag.Parse() var err error log.Printf("Connecting to db: %s\n", *dbPath) @@ -644,6 +645,8 @@ func main() { } defer db.Close() + baseDocDir = *docPath + log.Printf("baseDocDir: %s\n", baseDocDir) http.HandleFunc("/docs/", handleFileServer(baseDocDir, "/docs/")) //http.Handle("/docs/", http.StripPrefix("/docs/", http.FileServer(http.Dir("docs")))) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) |
