-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.go
48 lines (37 loc) · 898 Bytes
/
web.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
45
46
47
48
package main
import (
"fmt"
_ "github.com/ChimeraCoder/anaconda"
"github.com/gorilla/mux"
_ "html/template"
"log"
"net/http"
_ "os"
)
func main() {
r := mux.NewRouter()
api := createTwitterAPI()
//port := os.Getenv("HTTP_PLATFORM_PORT")
r.HandleFunc("/twitter", twitterHandler(api))
r.HandleFunc("/", indexHandler)
http.Handle("/", r)
log.Println("Server listening at localhost:3000")
http.ListenAndServe(":3000", nil)
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
// templ, err := template.ParseFiles("templates/index.html")
// if err != nil {
// handleWebErr(w, err)
// return
// }
// err = templ.Execute(w, nil)
// if err != nil {
// handleWebErr(w, err)
// return
// }
fmt.Fprint(w, "Madhav is awesome")
}
func handleWebErr(w http.ResponseWriter, err error) {
log.Panic(err)
http.Error(w, "Internal server error: "+err.Error(), 500)
}