aboutsummaryrefslogtreecommitdiff
path: root/app/_main.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/_main.py')
-rw-r--r--app/_main.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/app/_main.py b/app/_main.py
index 3f93804..3c2a973 100644
--- a/app/_main.py
+++ b/app/_main.py
@@ -1,38 +1,37 @@
#!/usr/bin/env python3
from flask import (Blueprint as _Blueprint, render_template as _template,
- request as _r)
+ request as _r, current_app as _app)
from textoutpc import tohtml as _translate
__all__ = ["main"]
main = _Blueprint('main', __name__)
-@main.route('/', methods = ['GET'])
-@main.route('/index.html', methods = ['GET'])
-def _empty_page():
- """ Page sans entrée. """
-
- return _template('page.html', result = None, text = '')
-
-@main.route('/index.html', methods = ['POST'])
+@main.route('/', methods = ['GET', 'POST'])
+@main.route('/index.html', methods = ['GET', 'POST'])
def _process_page():
""" Page avec entrée. """
result = None
text = ''
- if 'text' in _r.form:
+ if _r.method == 'POST' and 'text' in _r.form:
text = _r.form['text'].strip()
if text:
result = _translate(text)
+ else:
+ text = _app.config['TEXT_DEFAULT']
+ result = _app.config['TEXT_DEFAULT_TRANSLATED']
- return _template('page.html', result = result, text = text)
+ return _template('page.html', text = text, result = result,
+ url = _app.config['URL'])
@main.route('/guide.html', methods = ['GET'])
def _guide_page():
""" Page de guide. """
- return _template('guide.html')
+ return _template('guide.html', content = _app.config['TEXT_GUIDE'],
+ url = _app.config['URL'])
# End of file.