-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunx.py
More file actions
31 lines (24 loc) · 851 Bytes
/
funx.py
File metadata and controls
31 lines (24 loc) · 851 Bytes
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
from flask import Flask, render_template, request
from EvalVisitor import EvalVisitor
app = Flask(__name__)
results = []
visitor = EvalVisitor()
if __name__ == '__main__':
app.run()
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
input_text = request.form['input']
try:
str_result = str(visitor.Result(input_text))
s = "Input: " + input_text + ", Output: " + str_result
except Exception as e:
s = "Input: " + input_text + ", Output: " + str(e)
results.append(s)
if len(results) > 5:
results.pop(0)
functions = visitor.getFunctions()
return render_template(
'base.html', input_text=input_text, results=results, functions=functions)
else:
return render_template('base.html')