Commit 94ab78dd14d0a5402f0ee037e3ac47cbdf7ea3a9

Authored by David E. Shere
1 parent 76c173cb8c
Exists in master

added a comment basically to test repository access

Showing 1 changed file with 3 additions and 0 deletions Inline Diff

1 /*
2 Example key / store webapp using Go.
3 */
package webhash 1 4 package webhash
2 5
import ( 3 6 import (
"html/template" 4 7 "html/template"
"net/http" 5 8 "net/http"
6 9
"appengine" 7 10 "appengine"
"appengine/datastore" 8 11 "appengine/datastore"
) 9 12 )
10 13
func init() { 11 14 func init() {
http.HandleFunc("/", rootHandler) 12 15 http.HandleFunc("/", rootHandler)
} 13 16 }
14 17
type User struct { 15 18 type User struct {
UserID string 16 19 UserID string
Value string 17 20 Value string
} 18 21 }
19 22
func rootHandler(w http.ResponseWriter, r *http.Request) { 20 23 func rootHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r) 21 24 c := appengine.NewContext(r)
u := User{ 22 25 u := User{
UserID: r.FormValue("userid"), 23 26 UserID: r.FormValue("userid"),
Value: r.FormValue("value"), 24 27 Value: r.FormValue("value"),
} 25 28 }
k := datastore.NewKey(c, "User", u.UserID, 0, nil) 26 29 k := datastore.NewKey(c, "User", u.UserID, 0, nil)
27 30
if u.Value == "" { 28 31 if u.Value == "" {
datastore.Get(c, k, &u) 29 32 datastore.Get(c, k, &u)
} else { 30 33 } else {
datastore.Put(c, k, &u) 31 34 datastore.Put(c, k, &u)
} 32 35 }
33 36
rootTemplate.Execute(w, u.Value) 34 37 rootTemplate.Execute(w, u.Value)
35 38
} 36 39 }
37 40
var rootTemplate = template.Must(template.New("root").Parse(rootTemplateHTML)) 38 41 var rootTemplate = template.Must(template.New("root").Parse(rootTemplateHTML))
39 42
const rootTemplateHTML = ` 40 43 const rootTemplateHTML = `
<!DOCTYPE HTML> 41 44 <!DOCTYPE HTML>