-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_main.py
53 lines (36 loc) · 1.04 KB
/
app_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
from flask import Flask
from time import sleep
from bs4 import BeautifulSoup as soup
html = soup(open('static/ui.html', 'r', encoding='utf-8').read(), features='html.parser')
app = Flask(__name__)
def output(button_key):
# finds <textarea id="output"> and changes its value according to the pressed button
output_tag = html.find('textarea', attrs={'id': 'output'})
output_tag.string.replace_with(button_key)
print(f' {output_tag}')
sleep(2)
output_tag.string.replace_with(' ')
@app.route('/', methods=['GET','POST'])
def ui():
return str(html)
@app.route('/a')
def a():
#playsound(f'{getcwd()}/A.wav') # actual path + sound file name
output('a')
return ('')
@app.route('/b')
def b():
#playsound(f'{getcwd()}/B.wav')
output('b')
return ('')
@app.route('/c')
def c():
#playsound(f'{getcwd()}/C.wav')
output('c')
return ('')
@app.route('/d')
def d():
output('d')
return ('')
if __name__ == '__main__':
app.run()