/
app.py
55 lines (40 loc) · 1.57 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
import flask, flask.views
import calc_tools as ct
import params_processor as proc
import logging
logger = logging.getLogger(__name__)
app = flask.Flask(__name__)
app.debug = True
app.secret_key = "bacon"
default_params, params_comments = ct.get_and_store_params(load_from_dropbox=True)
class Main(proc.EgrixCalcView):
def get(self):
return flask.render_template('index.html',d = default_params, c = params_comments)
def post(self):
logger.info("post request in Main")
messages_to_flash, html_path = self.process_params('index')
logger.info("html_path\n%s" % (html_path,))
flask.flash(messages_to_flash[0])
flask.flash(messages_to_flash[1])
return flask.redirect(flask.url_for('index'))
class AllParams(proc.EgrixCalcView):
def get(self):
global default_params, params_comments
return flask.render_template('all_params.html',d = default_params, c = params_comments)
def post(self):
logger.info("post request in AllParams")
messages_to_flash, html_path = self.process_params('all_params')
logger.info("html_path\n%s" % (html_path,))
flask.flash(messages_to_flash[0])
flask.flash(messages_to_flash[1])
return flask.redirect(flask.url_for('all_params'))
app.add_url_rule('/',
view_func=Main.as_view('index'),
methods=['GET', 'POST'])
app.add_url_rule('/all_params/',
view_func=AllParams.as_view('all_params'),
methods=['GET', 'POST'])
if __name__ == '__main__':
ct.setup_logging()
app.run()