-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
109 lines (86 loc) · 3.47 KB
/
main.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import webapp2
######################### Jinja Scaffold ###############################
import os
import jinja2
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
autoescape = True)
class Handler(webapp2.RequestHandler):
def write(self,*a,**kw):
self.response.out.write(*a,**kw)
def render_str(self,template,**params):
t = jinja_env.get_template(template)
return t.render(params)
def render(self,template,**kw):
self.write(self.render_str(template,**kw))
################################ / #####################################
class MainPage(Handler):
def get(self):
self.render("root.html")
################## olympiad-problem-classifier ########################
import classifier
class Olympiad_problem_classifier(Handler):
def get(self):
self.render("olympiad_problem_classifier.html",
statement = "Every even integer greater than 2 can be expressed as the sum of two primes.",
message = [""])
def post(self):
statement = self.request.get("statement")
message = classifier.classify_statement(statement)
self.render("olympiad_problem_classifier.html",statement = statement, message = message)
######################### AutoTabber ##################################
import autoTabber
class Auto_tabber(Handler):
def get(self):
self.render("auto_tabber.html",
stringGuitarNotes = "D7 G5 B5 e5 D6e7 B5 G5 e7 D5e8 B5 G5 e8 D4e2 B3 G2 e2 D3e0 B1 G2 B1 e0 B1 G2 A2G0B0 A0G2B1 A0G2B1",
wPinky = "1",
wIndexFingerPosition = "0.1",
wIFPDelta = "2",
showFingerAnnotations = "N",
explainScore = "N",
message = [""])
def post(self):
stringGuitarNotes = self.request.get("stringGuitarNotes")
wPinky = self.request.get("wPinky")
wIndexFingerPosition = self.request.get("wIndexFingerPosition")
wIFPDelta = self.request.get("wIFPDelta")
showFingerAnnotations = self.request.get("showFingerAnnotations")
explainScore = self.request.get("explainScore")
print("wPinky = %s"%wPinky)
print("wIndexFingerPosition = %s"%wIndexFingerPosition)
print("wIFPDelta = %s"%wIFPDelta)
print("showFingerAnnotations = %s"%showFingerAnnotations)
print("explainScore = %s"%explainScore)
message = autoTabber.autoTab(stringGuitarNotes,wPinky,wIndexFingerPosition,wIFPDelta)
if showFingerAnnotations == "N":
message[1] = ""
if explainScore == "N":
message[2] = ""
self.render("auto_tabber.html",
stringGuitarNotes = stringGuitarNotes,
wPinky = wPinky,
wIndexFingerPosition = wIndexFingerPosition,
wIFPDelta = wIFPDelta,
showFingerAnnotations = showFingerAnnotations,
explainScore = explainScore,
message = message)
###################### AutoTabberSamples ##############################
import autoTabber
class Auto_tabber_samples(Handler):
def get(self):
self.render("auto_tabber_samples.html")
######################### /robots.txt ##################################
class Robots(Handler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.render("robots.html")
############################ Handlers ##################################
application = webapp2.WSGIApplication([
('/', MainPage),
('/olympiad_problem_classifier',Olympiad_problem_classifier),
('/auto_tabber',Auto_tabber),
('/auto_tabber_samples',Auto_tabber_samples),
('/robots.txt',Robots)
], debug=True)
########################################################################