simple.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from google.appengine.ext import webapp
  2. from google.appengine.ext.webapp.util import run_wsgi_app
  3. import os
  4. import json
  5. from google.appengine.ext import db
  6. class MainPage(webapp.RequestHandler):
  7. def get(self):
  8. self.response.headers['Content-Type'] = 'text/html'
  9. path = os.path.join(os.path.dirname(__file__), 'index.html')
  10. self.response.out.write(open(path).read())
  11. class TurtlePage(webapp.RequestHandler):
  12. def get(self):
  13. self.response.headers['Content-Type'] = 'text/html'
  14. path = os.path.join(os.path.dirname(__file__), 'turtle.html')
  15. self.response.out.write(open(path).read())
  16. class IdePage(webapp.RequestHandler):
  17. def get(self):
  18. self.response.headers['Content-Type'] = 'text/html'
  19. path = os.path.join(os.path.dirname(__file__), 'ide/index.html')
  20. self.response.out.write(open(path).read())
  21. class TestResult(db.Model):
  22. browsername = db.StringProperty()
  23. browserversion = db.StringProperty()
  24. browseros = db.StringProperty()
  25. version = db.StringProperty()
  26. rc = db.StringProperty()
  27. results = db.TextProperty()
  28. date = db.DateTimeProperty(auto_now_add=True)
  29. class TestResults(webapp.RequestHandler):
  30. def post(self):
  31. data = json.loads(self.request.body)
  32. tr = TestResult()
  33. tr.browsername = str(data['browsername'])
  34. tr.browserversion = str(data['browserversion'])
  35. tr.browseros = str(data['browseros'])
  36. tr.version = str(data['version'])
  37. tr.rc = str(data['rc'])
  38. tr.results = str(data['results'])
  39. tr.put()
  40. self.response.headers['Content-Type'] = 'application/json'
  41. self.response.out.write("{result:'ok'}")
  42. application = webapp.WSGIApplication(
  43. [('/', MainPage),
  44. ('/testresults', TestResults),
  45. ('/turtle', TurtlePage),
  46. ('/ide', IdePage)
  47. ],
  48. debug=False)
  49. def main():
  50. run_wsgi_app(application)
  51. if __name__ == "__main__":
  52. main()