forked from philipk19238/browser-talk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flask_test.py
87 lines (68 loc) · 2.21 KB
/
flask_test.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
from flask import Flask, request, render_template, redirect, url_for
from selenium import webdriver
import utils.chrome_app
path = r'/Users/andrew/.wdm/drivers/chromedriver/79.0.3945.36/mac64/chromedriver'
driver = webdriver.Chrome(path)
#driver.maximize_window()
browser_name_list = []
app = Flask(__name__)
@app.route('/')
def index():
'''
Main page with "run script" and "clear" commands
'''
return render_template('index.html')
@app.route('/foo', methods=['GET','POST'])
def foo():
'''
Text command box for the purposes of testing selenium driver
'''
from utils.chrome_app import Chrome_Command, Voice
'''
try:
text = request.form['text']
print(text)
if "new tab" in text:
user_command = Chrome_Command()
user_command.new_tab()
except:
return render_template('textbox.html')
'''
voice = Voice()
voice.initialize_recognition()
return render_template('textbox.html')
@app.route('/foo', methods=['GET','POST'])
def get_command():
'''
Executing the command given by text using the chrome_app
module
'''
'''
text = 'chrome new tab'
utils.chrome_app.decision_tree(text)
#If no dictionary exists, just return the same page
'''
return render_template('textbox.html')
@app.route('/boo', methods=['GET', 'POST'])
def boo():
'''
Printing and deleting previous selenium commmands
'''
outfile = open('templates/index.html', 'w')
outfile.write("""
<head>
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='styles/mainpage.css') }}">
</head>
<body>
<div id="wrapper">
<form action="/foo" method="POST"><input type="submit" value="Run Script"></form>
<form action="/boo" method="POST"><input type="submit" value="Clear"></form>
</div>
</body>
""")
outfile.close()
textfile = open('templates/text.html', 'w')
textfile.write("""""")
return redirect('/')
if __name__ == '__main__':
app.run(debug = True, port = 5014)