-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
executable file
·48 lines (37 loc) · 1.35 KB
/
example.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
#!/usr/bin/env python
from flask import Flask, render_template
from flask.ext.wtf import Form
from wtforms import SubmitField, validators
from sweep_field import RowFormField, SweepForm
app = Flask(__name__)
app.config['SECRET_KEY'] = 'Shh!'
app.config['WTF_CSRF_ENABLED'] = False
class ExampleForm(Form):
sweep1 = RowFormField(SweepForm, label='Learning Rate', tooltip='Learning rate is the rate of learning')
sweep2 = RowFormField(SweepForm, label='Bias', tooltip='Bias of something')
submit = SubmitField('POST')
@app.route('/', methods=['get', 'post'])
def home():
form = ExampleForm()
if form.validate_on_submit():
print '==============='
print str(form.sweep1.label), form.sweep1.range()
print str(form.sweep2.label), form.sweep2.range()
print '==============='
print len(form.sweep1.range()) * len(form.sweep2.range())
else:
print form.errors
return render_template('example.html', form=form)
from flask import request
def shutdown_server():
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
@app.route('/shutdown', methods=['POST'])
def shutdown():
shutdown_server()
return 'Server shutting down...'
if __name__ == '__main__':
#shutdown_server()
app.run(debug=True)