blob: 47e45cd81830a255b73b8e6ee4ca0ca3158689c3 (
plain)
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
|
# python import
import logging
# ..
from gettext import gettext as _
# make module
from flask import jsonify, Module, request
_module = Module(__name__)
# bewype import
from bewype.flask import app
# nutriweb import
from nutriweb.controllers.base import render as r
# get application logger
logger = logging.getLogger('nutriweb')
@_module.route('/eating', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
if 'difficutly' in request.form:
_word = request.form['difficutly']
elif 'difficutly-ajax' in request.form:
_ajax_content = {
'word': request.form['difficutly-ajax']
}
return jsonify(_ajax_content)
else:
_word = '??'
else:
_word = 'null'
_content = {
'title': [_('Eating'), 'test'],
'other_dict': {
'word1': _word,
'word2': 'deux',
}
}
return r('nutriweb/eating.html', **_content)
# do register
app.register_module(_module)
|