-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (28 loc) · 693 Bytes
/
main.go
File metadata and controls
33 lines (28 loc) · 693 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
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/a-berahman/batamrin/common"
"github.com/a-berahman/batamrin/mainPage"
"github.com/joho/godotenv"
)
func main() {
//handle url path to handler
http.HandleFunc("/", mainPage.Index)
http.HandleFunc("/index", mainPage.Index)
//define public resources path
http.Handle("/public/", http.StripPrefix("/public", http.FileServer(http.Dir("public"))))
//load enviroment variables
err := godotenv.Load(common.EnvConfig)
if err != nil {
log.Fatal("load enviroment face to : ", err)
}
port := os.Getenv("PORT")
if port == "" {
port = "123"
}
fmt.Println("live on port:", port)
http.ListenAndServe(":"+port, nil)
}