-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
213 lines (175 loc) · 4.85 KB
/
app.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
from flask import Flask, render_template, request, redirect, url_for
import threading, time, json
app = Flask(__name__)
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
@app.route('/Period')
def Period():
images = json.load(open('static/period_room/image_details.py', 'rb'))
return render_template("Period.html",images=images)
# PAGE ROUTES
@app.route('/Fee/young')
def FeeYoung():
return render_template("Fee.html", age = "young")
@app.route('/Fee/old')
def FeeOld():
return render_template("Fee.html", age = "old")
@app.route('/Fee/add')
def FeeAdd():
f = open('currentFont.txt', 'r')
font = f.readline()
f.close()
return render_template("FeeAdd.html", font = font)
@app.route('/Fee/faces')
def FeeTextOld():
return render_template("FeeTextOld.html")
@app.route('/Fee/text')
def FeeTextYoung():
return render_template("FeeTextYoung.html")
@app.route('/Hutchins')
def Hutchins():
return render_template("Hutchins.html")
@app.route("/Tanner")
def Tanner():
return render_template('Tanner.html')
@app.route("/Stephenson")
def Stephenson():
import glob
imgs = glob.glob("static/image_rotator/*.jpg")
return render_template('Stephenson.html', imgs = imgs)
@app.route("/Stephenson/text")
def imageRotatorText():
import json
f = open("allImagesText.txt")
allLines = f.read()
f.close()
print(json.loads(allLines))
return render_template('StephensonText.html', allLines = json.loads(allLines))
@app.route('/introduction')
def introduction():
return render_template("introduction.html")
@app.route('/Frost')
def Frost():
return render_template("Frost.html")
@app.route('/Stewart')
def Stewart():
return render_template("Stewart.html")
@app.route('/HutchShinFairWeather')
def HutchShinFairWeather():
return render_template("HutchShinFairWeather.html")
@app.route('/HutchShinFairWeather/video')
def HutchShinFairWeatherVideo():
return render_template("HutchShinFairWeatherVideo.html")
@app.route('/vetWords')
def vetWords():
f = open('pendingWords.txt', 'r')
words = f.readlines()
print(words)
f.close()
f = open('words.txt', 'r')
vettedWords = f.readlines()
return render_template("vetWords.html", words = words, vettedWords = vettedWords)
# AJAX ROUTES
@app.route("/setImageRotator/<imgPath>")
def setImageRotator(imgPath):
f = open("currentImageRotator.txt", "w")
f.write(imgPath)
f.close()
print(imgPath)
return "success"
@app.route("/getImageRotatorText")
def getImageRotatorText():
f = open("currentImageRotator.txt", 'r')
currentImg = f.read()
f.close()
return currentImg
@app.route('/getWords')
def getWords():
f = open('currentFont.txt', 'r')
font = f.readline()
# print(font)
f.close()
f = open('words.txt', 'r')
words = f.read()
f.close()
f = open('muteDisplay.txt', 'r')
muter = f.read()
f.close()
return muter + "||" + font + "||" + words
@app.route('/approve/<word>')
def approve(word):
f = open('words.txt', 'a')
f.write(word + "\n")
f.close()
with open('pendingWords.txt', 'r') as f:
lines = f.readlines()
with open('pendingWords.txt', 'w') as f:
# Remove word from pendingWords that was approved
for line in lines:
print("Line: ", line.strip())
print("word: ", word.strip())
print("Evaluated: ", line.strip() != word.strip())
if line.strip() != word.strip():
print("adding", word, line.strip("\n"))
f.write(line)
else:
print("Skipping: ", line)
f = open('pendingWords.txt', 'r')
words = f.read()
f.close()
if len(words) > 0:
return words
else:
return ""
@app.route('/removeWord', methods = ["POST"])
def removeWord():
word = request.form.get("word")
f = open('pendingWords.txt', 'r')
words = f.read()
words = words.replace(word, " ")
f = open('pendingWords.txt', 'w')
f.write(words)
f.close()
return redirect(url_for('vetWords'))
@app.route('/sendWord/<age>/<word>')
def sendWord(age, word):
f = open('pendingWords.txt', 'a')
f.write(age + ": " + word.strip() + ":|: \n")
f.close()
return word
@app.route('/sendFont/<font>')
def sendFont(font):
f = open('currentFont.txt', 'r')
cFont = f.read()
f.close()
print("Changing font to ", font, "||", cFont)
if cFont != font:
print("Writing new font ", font)
f = open('currentFont.txt', 'w')
f.write(font)
f.close()
return font
@app.route('/getFont')
def getFont():
f = open('currentFont.txt', 'r')
font = f.read()
print("Sending font: ", font)
f.close()
return font
def updateMuteState():
states = {"true": "false",
"false": "true",
"": "true"}
f = open('muteDisplay.txt', 'r')
currentState = f.read()
f = open('muteDisplay.txt', 'w')
f.write(states[currentState])
f.close()
@app.route('/muteDisplay')
def muteDisplay():
updateMuteState()
threading.Timer(20.0, updateMuteState).start()
f = open('muteDisplay.txt', 'r')
currentState = f.read()
f.close()
return currentState