-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
40 lines (26 loc) · 817 Bytes
/
hello.py
File metadata and controls
40 lines (26 loc) · 817 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
32
33
34
35
36
37
38
39
40
from flask import Flask
from flask import render_template
from flask import request
from algorithm import *
import yaml
app = Flask(__name__)
import logging
logging.basicConfig(filename='example.log',level=logging.DEBUG)
@app.route('/')
def hello_world():
return 'Hello, World!'
@app.route('/compute', methods=['GET', 'POST'])
def compute():
if request.method == 'GET':
return render_template('compute.html', result=0)
else:
input1 = request.form['input1']
app.logger.debug(input1)
yamlInput1 = yaml.safe_load(input1)
app.logger.debug(yamlInput1)
print 'yamlInput1: ' + str(yamlInput1)
result = sum(yamlInput1)
print result
return render_template('compute.html', result=result)
if __name__ == "__main__":
app.run()