Mercurial > piecrust2
diff piecrust/admin/wsgiutil.py @ 778:5e91bc0e3b4d
internal: Move admin panel code into the piecrust package.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 16 Jul 2016 15:02:24 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/piecrust/admin/wsgiutil.py Sat Jul 16 15:02:24 2016 +0200 @@ -0,0 +1,24 @@ +import logging + + +logger = logging.getLogger() + + +def get_wsgi_app(admin_root=None, log_file=None, + max_log_bytes=4096, log_backup_count=0, + log_level=logging.INFO): + 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) + + logger.debug("Creating WSGI application.") + es = {} + if admin_root: + es['FOODTRUCK_ROOT'] = admin_root + from .web import create_foodtruck_app + app = create_foodtruck_app(es) + return app +