-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (35 loc) · 926 Bytes
/
Copy pathmain.go
File metadata and controls
40 lines (35 loc) · 926 Bytes
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 (
"fmt"
"forum/controllers"
DBM "forum/repository"
"forum/tools"
"forum/tools/riot"
_ "forum/tools/session"
"log"
"math/rand"
"net/http"
"os"
"time"
)
func init() {
err := tools.LoadEnv(".env")
rand.Seed(time.Now().Unix())
riot.API.SetKey(os.Getenv("riot_key"))
if err != nil {
log.Fatal(err)
}
}
func main() {
DBM.InitializeDatabase("forum_database.db")
http.Handle("/", &controllers.ClientController{})
http.Handle("/api/", &controllers.APIController{})
fmt.Println("Start...")
fmt.Println("\thttp://localhost:8080")
tools.Openbrowser("http://localhost:8080")
//static
http.Handle("/style/", http.StripPrefix("/style/", http.FileServer(http.Dir("./src/css"))))
http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(http.Dir("./src/img"))))
http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("./src/js"))))
http.ListenAndServe(":8080", nil)
}