Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added members only access. added members can post updates

  • Loading branch information...
commit 4926154653caac9d67e0a94d4c300806b7d0e9fb 1 parent 3928910
@progrium progrium authored
Showing with 22 additions and 3 deletions.
  1. +2 −1  app.yaml
  2. +12 −1 main.py
  3. +8 −1 templates/main.html
View
3  app.yaml
@@ -13,4 +13,5 @@ handlers:
- url: /static
static_dir: static
- url: .*
- script: main.py
+ script: main.py
+ login: required
View
13 main.py
@@ -1,4 +1,5 @@
from google.appengine.ext import webapp, db
+from google.appengine.api import urlfetch, memcache, users
from google.appengine.ext.webapp import util, template
class Update(db.Model):
@@ -10,8 +11,18 @@ class Update(db.Model):
class MainHandler(webapp.RequestHandler):
def get(self):
- your_name = "Jeff"
+ user = users.get_current_user()
+ if user:
+ logout_url = users.create_logout_url('/')
+ else:
+ login_url = users.create_login_url('/')
+ updates = Update.all().order('-created')
self.response.out.write(template.render('templates/main.html', locals()))
+
+ def post(self):
+ update = Update(body=self.request.get('body'))
+ update.put()
+ self.redirect('/')
def main():
View
9 templates/main.html
@@ -1,6 +1,13 @@
{% extends 'base.html' %}
{% block content %}
-Hello world, {{your_name}}!
+<form method="post">
+ <textarea name="body"></textarea><br />
+ <input type="submit" value="Update" />
+</form>
+
+{% for update in updates %}
+<p>{{update.body}} | {{update.created|timesince}} ago | {{update.user.nickname}}</p>
+{% endfor %}
{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.