daily pastebin goal
58%
SHARE
TWEET

verwirrt

a guest May 16th, 2018 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func hello(w http.ResponseWriter, r *http.Request) {
  2.     //fmt.Fprintf(w, "Hello!")
  3.  
  4.     var t *template.Template
  5.     t, _ = template.ParseFiles("layout.tmpl", "test.tmpl")
  6.    
  7.     t.ExecuteTemplate(w, "layout", nil)
  8. }
  9.  
  10. func world(w http.ResponseWriter, r *http.Request) {
  11.     fmt.Fprintf(w, "World!")
  12. }
  13.  
  14. func main() {
  15.  
  16.     server := http.Server{
  17.         Addr: ":8080",
  18.     }
  19.  
  20.     http.HandleFunc("/hello", hello)
  21.     http.HandleFunc("/world", world)
  22.  
  23.     server.ListenAndServe()
  24.  
  25. }
RAW Paste Data
Top