-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
36 lines (31 loc) · 1.14 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
from flask import Flask
from flask import request
from script.solver import *
from doctest import testmod
app = Flask(__name__)
@app.route("/")
def index():
phone_number = request.args.get("phone_number", "").replace('"', "")
word_list = request.args.get("word_list", "")
if phone_number and word_list:
try:
output = str(solver(phone_number, sanatise_array(word_list), keypad))
except ValueError:
output = "Oops! That was no valid phone number. Try again..."
else:
output = "[]"
return (
"""<form action="" method="get">
Phone number "3662277": <input type="text" name="phone_number">
<br>
<br>
Array of words eg. ["foo", "bar", "baz"]: <input type="text" name="word_list">
<input type="submit" value="Submit">
</form>"""
+ "Output: "
+ output
)
if __name__ == "__main__":
# This line is meant for doctest, set verbose to true to see the result of the test
testmod(verbose=False)
app.run(host='0.0.0.0', port=80, debug=True)