Implemented configuration file functionality

For site name, port number and data directory
This commit is contained in:
2026-04-29 22:08:23 +02:00
parent 267383a45b
commit 64e5c26bc0
2 changed files with 42 additions and 3 deletions
+6 -3
View File
@@ -6,13 +6,16 @@ import (
"net/http"
"os"
"192.168.1.180/odonax/filehost-athome/config"
"192.168.1.180/odonax/filehost-athome/database"
)
func main() {
os.MkdirAll("data/files", 0755)
cfg := config.Load("config.json")
db := database.Open("data/hub.db")
os.MkdirAll(cfg.DataDir+"/files", 0755)
db := database.Open(cfg.DataDir+"/hub.db")
defer db.Close()
tmpl, err := template.ParseFiles("templates/home.html")
@@ -22,7 +25,7 @@ func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
data := map[string]string{
"Name": "Filehost at home",
"Name": cfg.SiteName,
"Description": "This is where you'll own your files and share them freely.",
}
tmpl.Execute(w, data)