-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
44 lines (35 loc) · 969 Bytes
/
server.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
41
42
43
44
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
// about page handler
http.HandleFunc("/about",aboutPage)
// login page handler
http.HandleFunc("/login",loginPage)
http.HandleFunc("/",homePage)
http.HandleFunc("/auth",authentication)
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request){
fmt.Fprintf(w, "Hello!")
})
fmt.Printf("Starting server at port 8080\n")
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal(err)
}
}
func aboutPage(w http.ResponseWriter, r *http.Request){
fmt.Fprintf(w, "about page")
}
func loginPage(w http.ResponseWriter, r *http.Request){
http.ServeFile(w, r, "./static/login.html")
}
func homePage(w http.ResponseWriter, r *http.Request){
http.ServeFile(w, r, "./static/index.html")
}
func authentication(w http.ResponseWriter, r *http.Request){
// admin = "chimi"
// password = "meopen"
fmt.Println("working")
}