Mercurial > piecrust2
view piecrust/wsgiutil/__init__.py @ 924:1bb704434ee2
formatting: Remove segment parts, you can use template tags instead.
Segment parts were used to switch formatters insides a given content segment,
but that's also achievable with template tags like `pcformat` in Jinja to
some degree. It's not totally the same but removing it simplifies the code
and improves performance.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 01 Oct 2017 20:36:04 -0700 |
parents | b4156f5d4368 |
children | 7ecb946bfafd |
line wrap: on
line source
import logging from piecrust.serving.server import WsgiServer def _setup_logging(log_file, log_level, max_log_bytes, log_backup_count): if log_file: from logging.handlers import RotatingFileHandler handler = RotatingFileHandler(log_file, maxBytes=max_log_bytes, backupCount=log_backup_count) handler.setLevel(log_level) logging.getLogger().addHandler(handler) def get_app(root_dir, *, cache_key='prod', enable_debug_info=False, log_file=None, log_level=logging.INFO, log_backup_count=0, max_log_bytes=4096): _setup_logging(log_file, log_level, max_log_bytes, log_backup_count) app = WsgiServer(root_dir, cache_key=cache_key, enable_debug_info=enable_debug_info) return app def get_admin_app(root_dir, *, url_prefix='pc-admin', log_file=None, log_level=logging.INFO, log_backup_count=0, max_log_bytes=4096): _setup_logging(log_file, log_level, max_log_bytes, log_backup_count) es = { 'FOODTRUCK_ROOT': root_dir, 'FOODTRUCK_URL_PREFIX': url_prefix} from piecrust.admin.web import create_foodtruck_app app = create_foodtruck_app(es) return app