From 4b7fe9239be243bc082b8a45192071bc479aaeaf Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Tue, 14 May 2013 09:42:14 -0400 Subject: [PATCH] Remove the GAE robot sample. Reviewed in https://codereview.appspot.com/9368044/. --- samples/appengine_with_robots/README | 5 -- samples/appengine_with_robots/app.yaml | 9 --- samples/appengine_with_robots/main.py | 81 ---------------------- samples/appengine_with_robots/welcome.html | 18 ----- 4 files changed, 113 deletions(-) delete mode 100644 samples/appengine_with_robots/README delete mode 100644 samples/appengine_with_robots/app.yaml delete mode 100644 samples/appengine_with_robots/main.py delete mode 100644 samples/appengine_with_robots/welcome.html diff --git a/samples/appengine_with_robots/README b/samples/appengine_with_robots/README deleted file mode 100644 index 277df01..0000000 --- a/samples/appengine_with_robots/README +++ /dev/null @@ -1,5 +0,0 @@ -Sample application that demonstrates how to use AppAssertionCredentials -to access an API. - -api: urlshortener -keywords: appengine oauth2 diff --git a/samples/appengine_with_robots/app.yaml b/samples/appengine_with_robots/app.yaml deleted file mode 100644 index c313482..0000000 --- a/samples/appengine_with_robots/app.yaml +++ /dev/null @@ -1,9 +0,0 @@ -application: robot-sample -version: 2 -runtime: python -api_version: 1 - -handlers: -- url: .* - script: main.py - diff --git a/samples/appengine_with_robots/main.py b/samples/appengine_with_robots/main.py deleted file mode 100644 index 7462024..0000000 --- a/samples/appengine_with_robots/main.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/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. -# -"""Starting template for Google App Engine applications. - -Use this project as a starting point if you are just beginning to build a -Google App Engine project which will access and manage data held under a role -account for the App Engine app. More information about using Google App Engine -apps to call Google APIs can be found in Scenario 1 of the following document: - - -""" - -__author__ = 'jcgregorio@google.com (Joe Gregorio)' - - -import httplib2 -import logging -import os -import pickle - -from apiclient.discovery import build -from google.appengine.api import memcache -from google.appengine.ext import webapp -from google.appengine.ext.webapp import template -from google.appengine.ext.webapp.util import run_wsgi_app -from oauth2client.appengine import AppAssertionCredentials - -credentials = AppAssertionCredentials( - scope='https://www.googleapis.com/auth/urlshortener') - -http = credentials.authorize(httplib2.Http(memcache)) -service = build("urlshortener", "v1", http=http) - - -class MainHandler(webapp.RequestHandler): - - def get(self): - path = os.path.join(os.path.dirname(__file__), 'welcome.html') - shortened = service.url().list().execute() - short_and_long = [] - if 'items' in shortened: - short_and_long = [(item["id"], item["longUrl"]) for item in - shortened["items"]] - - variables = { - 'short_and_long': short_and_long, - } - self.response.out.write(template.render(path, variables)) - - def post(self): - long_url = self.request.get("longUrl") - credentials.refresh(http) - shortened = service.url().insert(body={"longUrl": long_url}).execute() - self.redirect("/") - - -def main(): - application = webapp.WSGIApplication( - [ - ('/', MainHandler), - ], - debug=True) - run_wsgi_app(application) - - -if __name__ == '__main__': - main() diff --git a/samples/appengine_with_robots/welcome.html b/samples/appengine_with_robots/welcome.html deleted file mode 100644 index a035ce8..0000000 --- a/samples/appengine_with_robots/welcome.html +++ /dev/null @@ -1,18 +0,0 @@ - - - Welcome - - -
- Long Url: - -
- - - - {% for item in short_and_long %} - - {% endfor %} -
ShortenedOriginal
{{ item.0 }}{{ item.1 }}
- -