aboutsummaryrefslogtreecommitdiff
path: root/app/_main.py
blob: 3f93804fe4a89736a195e5ffb5e7f056adc5abc8 (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
#!/usr/bin/env python3

from flask import (Blueprint as _Blueprint, render_template as _template,
	request as _r)
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'])
def _process_page():
	""" Page avec entrée. """

	result = None
	text = ''

	if 'text' in _r.form:
		text = _r.form['text'].strip()
		if text:
			result = _translate(text)

	return _template('page.html', result = result, text = text)

@main.route('/guide.html', methods = ['GET'])
def _guide_page():
	""" Page de guide. """

	return _template('guide.html')

# End of file.