-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (26 loc) · 889 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
import os
import functools
import webapp2
from google.appengine.api import users
from google.appengine.ext import ndb
from utils import BaseHandler
DEBUG = os.environ.get("SERVER_SOFTWARE", "").startswith("Development/")
class Greeting(ndb.Model):
author = ndb.UserProperty()
content = ndb.StringProperty()
date = ndb.DateTimeProperty(auto_now_add=True)
class MainPage(BaseHandler):
def get(self):
grettings = Greeting.query()
self.render('index.html', {'greetings': grettings})
class GreetingHandler(BaseHandler):
def post(self):
greeting = Greeting()
greeting.author = users.get_current_user()
greeting.content = self.request.get('content')
greeting.put()
self.redirect('/')
app = webapp2.WSGIApplication([
('/', MainPage),
('/sign', GreetingHandler),], debug=DEBUG)