Mercurial > piecrust2
comparison piecrust/serving/wrappers.py @ 553:cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 08 Aug 2015 22:01:47 -0700 |
parents | 9612cfc6455a |
children | 9ab005db2592 |
comparison
equal
deleted
inserted
replaced
552:9612cfc6455a | 553:cc6f3dbe3048 |
---|---|
1 import os | 1 import os |
2 import logging | 2 import logging |
3 import threading | 3 import threading |
4 import urllib.request | 4 import urllib.request |
5 from piecrust.serving.server import Server | |
6 | 5 |
7 | 6 |
8 logger = logging.getLogger(__name__) | 7 logger = logging.getLogger(__name__) |
9 | 8 |
10 | 9 |
88 gunicorn_options = gunicorn_options or {} | 87 gunicorn_options = gunicorn_options or {} |
89 app_wrapper = PieCrustGunicornApplication(app, gunicorn_options) | 88 app_wrapper = PieCrustGunicornApplication(app, gunicorn_options) |
90 app_wrapper.run() | 89 app_wrapper.run() |
91 | 90 |
92 | 91 |
93 def _get_piecrust_server(root_dir, **kwargs): | 92 def _get_piecrust_server(root_dir, debug=False, sub_cache_dir=None, |
94 server = Server(root_dir, **kwargs) | 93 run_sse_check=None): |
95 app = server.getWsgiApp() | 94 from piecrust.serving.middlewares import ( |
95 StaticResourcesMiddleware, PieCrustDebugMiddleware) | |
96 from piecrust.serving.server import WsgiServer | |
97 app = WsgiServer(root_dir, debug=debug, sub_cache_dir=sub_cache_dir) | |
98 app = StaticResourcesMiddleware(app) | |
99 app = PieCrustDebugMiddleware(app, root_dir, | |
100 sub_cache_dir=sub_cache_dir, | |
101 run_sse_check=run_sse_check) | |
96 return app | 102 return app |
97 | 103 |