isundil 9 years ago
commit
e0cceb4b25
2 changed files with 39 additions and 0 deletions
  1. 7 0
      app.yaml
  2. 32 0
      tile/tile.go

+ 7 - 0
app.yaml

@@ -0,0 +1,7 @@
+runtime: go
+api_version: go1
+
+handlers:
+- url: /.*
+  script: _go_app
+

+ 32 - 0
tile/tile.go

@@ -0,0 +1,32 @@
+package tile
+
+import (
+	"fmt"
+	"net/http"
+	"time"
+
+	"appengine"
+	"appengine/datastore"
+)
+
+type Tile struct {
+	Created time.Time
+}
+
+func init() {
+	http.HandleFunc("/", handleRoolPath)
+}
+
+func handleRoolPath(w http.ResponseWriter, r *http.Request) {
+	ctx := appengine.NewContext(r)
+	key := datastore.NewKey(ctx, "Tile", "root", 0, nil)
+	tile := new(Tile)
+
+	if err := datastore.Get(ctx, key, tile); err != nil {
+		now := new time.Time()
+		tile.Created = now
+	}
+
+	fmt.Fprint(w, "Root slash " +tile.Created.String())
+}
+