From 656edf6ad94e695df19bac0a942fe0df5676d9c8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 17 Oct 2013 21:46:28 +0000 Subject: [PATCH] temp app for testing --- python2.7/testapp/app.yaml | 16 ++++++ python2.7/testapp/guestbook.py | 75 +++++++++++++++++++++++++ python2.7/testapp/guestbook.pyc | Bin 0 -> 2501 bytes python2.7/testapp/index.yaml | 22 ++++++++ python2.7/testapp/stylesheets/main.css | 4 ++ 5 files changed, 117 insertions(+) create mode 100644 python2.7/testapp/app.yaml create mode 100644 python2.7/testapp/guestbook.py create mode 100644 python2.7/testapp/guestbook.pyc create mode 100644 python2.7/testapp/index.yaml create mode 100644 python2.7/testapp/stylesheets/main.css diff --git a/python2.7/testapp/app.yaml b/python2.7/testapp/app.yaml new file mode 100644 index 00000000..3606d29c --- /dev/null +++ b/python2.7/testapp/app.yaml @@ -0,0 +1,16 @@ +application: indextest +version: 1 +runtime: python27 +api_version: 1 +threadsafe: yes + +builtins: +- remote_api: on + +handlers: +- url: .* + script: guestbook.app + +libraries: +- name: webapp2 + version: "2.5.2" diff --git a/python2.7/testapp/guestbook.py b/python2.7/testapp/guestbook.py new file mode 100644 index 00000000..afce3e9c --- /dev/null +++ b/python2.7/testapp/guestbook.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# Copyright 2007 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import cgi +import datetime +import webapp2 +import random +from google.appengine.ext import ndb +from google.appengine.api import users + +guestbook_key = ndb.Key('Guestbook', 'default_guestbook') + +class Greeting(ndb.Model): + author = ndb.UserProperty() + content = ndb.StringProperty() + date = ndb.DateTimeProperty(auto_now_add=True) + number = ndb.IntegerProperty() + +class MainPage(webapp2.RequestHandler): + def get(self): + self.response.out.write('') + + greetings = ndb.gql('SELECT * ' + 'FROM Greeting ' + 'WHERE ANCESTOR IS :1 ' + 'ORDER BY date DESC LIMIT 10', + guestbook_key) + + for greeting in greetings: + if greeting.author: + self.response.out.write('%s wrote:' % greeting.author.nickname()) + else: + self.response.out.write('An anonymous person wrote:') + self.response.out.write('
%s
' % + cgi.escape(greeting.content)) + + + self.response.out.write(""" +
+
+
+
+ + """) + + +class Guestbook(webapp2.RequestHandler): + def post(self): + greeting = Greeting(parent=guestbook_key) + greeting.number = random.randint(0,99999) + if users.get_current_user(): + greeting.author = users.get_current_user() + + greeting.content = self.request.get('content') + greeting.put() + self.redirect('/') + + +app = webapp2.WSGIApplication([ + ('/', MainPage), + ('/sign', Guestbook) +], debug=True) diff --git a/python2.7/testapp/guestbook.pyc b/python2.7/testapp/guestbook.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6ed019b390750b23fd8bd60242d21020db38107b GIT binary patch literal 2501 zcmbtWZEq7t5S~3dPHY^Kk`_T|mNQ7qBZ`EGN$Gy}zMjNoj+B)f5gy# zVhZsSln@Q)w4kAw@f{jEmUbwq(6~y&Dhbx9P_jhh8VzeCRF#gGDXdbsM6aQ-LSc=V zS*Jr-TBbKduZf-x8x*dPa_IPy71ZZ~CTlMQjk#deaxYVOiByvgahE2kRVE_Pkgm~d zA%^Sh#Gri{4#ofA*>4Mwrh+LAN7Ka;7Nu5&Hg!<y%TCNkScU4)FB9WMbM6Z7 zDU>pC8qJYod-pK(ZA=Q7346T?dk0|H0U!Vx?t=y<*tPt}XF%m!^`XmtNVqSfv9$S1zB^W*fHtv`P+bQ;NxD%q>{6{fESw(-c>nPeen!9qZPG zBR?qC>_?Z+WTGbAFPP@?v0cL!Qm95{)aK6baynWZxUU&}q6|ZJrbhVQ+%^nxlx0z( zHnCP|6sKwvO=Vhy@09v^JPiti{4)xYciB_-vQQ;9bcX*?aHnB;;HP1NaB+&dd}YJb zlfnJnyLq0(fzK_^