diff options
Diffstat (limited to 'app/__init__.py')
-rwxr-xr-x | app/__init__.py | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/app/__init__.py b/app/__init__.py index 76815f5..be89656 100755 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,42 +1,35 @@ #!/usr/bin/env python3 +#****************************************************************************** +# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr> +# This file is part of the textoutpc project, which is MIT-licensed. +#****************************************************************************** +""" textoutpc demonstration application definition. """ import os.path as _path -from flask import Flask as _Flask, render_template as _template, \ - request as _r -from textoutpc import tohtml as _translate +from flask import Flask as _Flask +from flask_assets import (Environment as _AssetsEnvironment, + Bundle as _AssetsBundle) -__all__ = ["app"] - -_gd = lambda x: _path.relpath(_path.join(_path.dirname(__file__), x)) -app = _Flask('textout', root_path = _path.curdir, - template_folder = _gd('templates'), static_folder = _gd('static'), - static_url_path = '/static') - -@app.route('/', methods = ['GET']) -@app.route('/index.html', methods = ['GET']) -def _empty_page(): - """ Page sans entrée. """ +from ._main import main as _main - return _template('page.html', result = None, text = '') - -@app.route('/index.html', methods = ['POST']) -def _process_page(): - """ Page avec entrée. """ +__all__ = ["app"] - result = None - text = '' +# Make the app and register blueprints. - if 'text' in _r.form: - text = _r.form['text'] - result = _translate(text) +_gd = lambda x: _path.relpath(_path.join(_path.dirname(__file__), x)) +app = _Flask('textout', + template_folder = _gd('templates'), + static_folder = _gd('static'), static_url_path = '/static') +app.register_blueprint(_main) - return _template('page.html', result = result, text = text) +# Add the assets. -@app.route('/guide.html', methods = ['GET']) -def _guide_page(): - """ Page de guide. """ +_assets = _AssetsEnvironment(app) - return _template('guide.html') +_assets.register('js', _AssetsBundle('js/elements.js', + filters = 'jsmin', output = 'index.js')) +_assets.register('css', _AssetsBundle('css/elements.scss', 'css/page.scss', + filters = ('scss', 'cssmin'), output = 'index.css')) # End of file. |