github.com/timstclair/heapster@v0.20.0-alpha1/Godeps/_workspace/src/google.golang.org/appengine/demos/helloworld/helloworld.go (about) 1 // Copyright 2014 Google Inc. All rights reserved. 2 // Use of this source code is governed by the Apache 2.0 3 // license that can be found in the LICENSE file. 4 5 // This example only works on Managed VMs. 6 // +build !appengine 7 8 package main 9 10 import ( 11 "html/template" 12 "net/http" 13 "time" 14 15 "google.golang.org/appengine" 16 "google.golang.org/appengine/log" 17 ) 18 19 var initTime = time.Now() 20 21 func main() { 22 http.HandleFunc("/", handle) 23 appengine.Main() 24 } 25 26 func handle(w http.ResponseWriter, r *http.Request) { 27 if r.URL.Path != "/" { 28 http.NotFound(w, r) 29 return 30 } 31 32 ctx := appengine.NewContext(r) 33 log.Infof(ctx, "Serving the front page.") 34 35 tmpl.Execute(w, time.Since(initTime)) 36 } 37 38 var tmpl = template.Must(template.New("front").Parse(` 39 <html><body> 40 41 <p> 42 Hello, World! 세상아 안녕! 43 </p> 44 45 <p> 46 This instance has been running for <em>{{.}}</em>. 47 </p> 48 49 </body></html> 50 `))