-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (31 loc) · 776 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"filebox/config"
"filebox/pages"
"net/http"
"os"
)
func main() {
server := http.NewServeMux()
os.Mkdir(pages.StoragePath, os.ModePerm)
server.HandleFunc("/accets/", pages.Accets)
server.HandleFunc("/login", pages.Login)
server.HandleFunc("/auth", pages.Auth)
server.HandleFunc("/", pages.Index)
conf, err := config.Load("FileBox.conf")
if err != nil {
conf = config.New("FileBox.conf")
conf.Add("Host", "127.0.0.1:80")
conf.Add("StoragePath", "storage")
conf.Save()
}
users, err := config.Load("Users.conf")
if err != nil {
users = config.New("Users.conf")
users.Add("Admin", "12345")
users.Save()
}
pages.Users = users
pages.StoragePath = conf.Get("StoragePath")
http.ListenAndServe(conf.Get("Host"), server)
}