Python flask_compress.Compress() Examples
The following are 1
code examples of flask_compress.Compress().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask_compress
, or try the search function
.
Example #1
Source File: __init__.py From scrapydweb with GNU General Public License v3.0 | 4 votes |
def create_app(test_config=None): app = Flask(__name__, instance_relative_config=True) app.config.from_mapping( SECRET_KEY='dev', ) # http://flask.pocoo.org/docs/1.0/config/#configuring-from-files app.config.from_object('scrapydweb.default_settings') if test_config is None: # load the instance config, if it exists, when not testing app.config.from_pyfile('config.py', silent=True) else: # load the test config if passed in app.config.from_mapping(test_config) @app.route('/hello') def hello(): return 'Hello, World!' handle_db(app) handle_route(app) handle_template_context(app) # @app.errorhandler(404) # def handle_error(error): # return ('Nothing Found', 404) # http://flask.pocoo.org/docs/1.0/patterns/errorpages/ app.register_error_handler(500, internal_server_error) # https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/playbooks_filters.html#other-useful-filters # https://stackoverflow.com/questions/12791216/how-do-i-use-regular-expressions-in-jinja2 # https://www.michaelcho.me/article/custom-jinja-template-filters-in-flask # http://flask.pocoo.org/docs/1.0/api/#flask.Flask.template_filter @app.template_filter() def regex_replace(s, find, replace): return re.sub(find, replace, s) app.jinja_env.variable_start_string = '{{ ' app.jinja_env.variable_end_string = ' }}' compress = Compress() compress.init_app(app) app.logger.setLevel(logging.DEBUG) return app