Commit 76c173cb8c897e2fcbc50427c2b8257456980779

Authored by David Shere
1 parent e5542180a2

removed commented out appengine/user import

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

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