Skip to content

Instantly share code, notes, and snippets.

@bassdread
Created September 20, 2013 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bassdread/6634631 to your computer and use it in GitHub Desktop.
Save bassdread/6634631 to your computer and use it in GitHub Desktop.
import webapp2
import cgi
from google.appengine.api import urlfetch
import json
import logging
class MainHandler(webapp2.RequestHandler):
red = 'http://www.blinkstick.com/d/<ID>/red.json'
green = 'http://www.blinkstick.com/d/<ID>/green.json'
def get(self):
self.response.write('Hello world!')
def post(self):
fixed = True
data = json.loads(self.request.body)
fixed = data.get('fixed', False)
if fixed:
result = urlfetch.fetch(self.green)
self.response.write(result.status_code)
else:
result = urlfetch.fetch(self.red)
self.response.write(result.status_code)
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment