# HG changeset patch # User Ludovic Chabant # Date 1431186538 25200 # Node ID d40b744a9d998c63d098722f77467fcae11b391e # Parent fe8a5881708820dcd869d995442622dd9120606d serve: Add a generic WSGI app factory. diff -r fe8a58817088 -r d40b744a9d99 piecrust/wsgiutil/__init__.py --- a/piecrust/wsgiutil/__init__.py Sat May 09 08:37:32 2015 -0700 +++ b/piecrust/wsgiutil/__init__.py Sat May 09 08:48:58 2015 -0700 @@ -0,0 +1,10 @@ +from piecrust.serving.server import Server + + +def get_app(root_dir, sub_cache_dir='prod', enable_debug_info=False): + server = Server(root_dir, + sub_cache_dir=sub_cache_dir, + enable_debug_info=enable_debug_info) + app = server.getWsgiApp() + return app + diff -r fe8a58817088 -r d40b744a9d99 piecrust/wsgiutil/cwdapp.py --- a/piecrust/wsgiutil/cwdapp.py Sat May 09 08:37:32 2015 -0700 +++ b/piecrust/wsgiutil/cwdapp.py Sat May 09 08:48:58 2015 -0700 @@ -2,12 +2,11 @@ # like Werkzeug or Gunicorn. It returns a WSGI app for serving a PieCrust # website located in the current working directory. import os -from piecrust.serving.server import Server +from piecrust.wsgiutil import get_app root_dir = os.getcwd() -server = Server(root_dir, sub_cache_dir='prod', enable_debug_info=False) -app = server.getWsgiApp() +app = get_app(root_dir) # Add this for `mod_wsgi`. application = app