repl.it
@badvillain01/

real_thevillainer

Go

No description

fork
loading
Files
  • main.go
  • static
  • templates
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
41
42
43
44
45
package main

import (
  "fmt"
  "net/http"
  "html/template"
  // "time"
)




func main() {
  http.HandleFunc("/", Home)

  http.HandleFunc("/uptimerobot", UpTimeRobot)

 // static files
  http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))

  fmt.Println("Server Started!!")
  http.ListenAndServe(":8080", nil)
}


type CurrentYear struct {
  Year  int
}



func Home(w http.ResponseWriter, r *http.Request) {

  temp := template.Must(template.ParseFiles("templates/index.html"))


  // data := CurrentYear{time.Now().Year()}
  
  temp.Execute(w, nil)
}


func UpTimeRobot(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintln(w, "Hello Uptimerobot")
}
?