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