Mercurial > piecrust2
annotate piecrust/serving/wrappers.py @ 663:3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 01 Mar 2016 22:27:28 -0800 |
parents | 9ab005db2592 |
children | 81d9c3a3a0b5 |
rev | line source |
---|---|
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import os |
558
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
2 import signal |
552
9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
Ludovic Chabant <ludovic@chabant.com>
parents:
374
diff
changeset
|
3 import logging |
9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
Ludovic Chabant <ludovic@chabant.com>
parents:
374
diff
changeset
|
4 import threading |
9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
Ludovic Chabant <ludovic@chabant.com>
parents:
374
diff
changeset
|
5 import urllib.request |
9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
Ludovic Chabant <ludovic@chabant.com>
parents:
374
diff
changeset
|
6 |
9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
Ludovic Chabant <ludovic@chabant.com>
parents:
374
diff
changeset
|
7 |
9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
Ludovic Chabant <ludovic@chabant.com>
parents:
374
diff
changeset
|
8 logger = logging.getLogger(__name__) |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 def run_werkzeug_server(root_dir, host, port, |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
12 debug_piecrust=False, theme_site=False, |
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
13 sub_cache_dir=None, |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 use_debugger=False, use_reloader=False): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 from werkzeug.serving import run_simple |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 def _run_sse_check(): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 # We don't want to run the processing loop here if this isn't |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 # the actual process that does the serving. In most cases it is, |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 # but if we're using Werkzeug's reloader, then it won't be the |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 # first time we get there... it will only be the correct process |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 # the second time, when the reloading process is spawned, with the |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 # `WERKZEUG_RUN_MAIN` variable set. |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 return (not use_reloader or |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 os.environ.get('WERKZEUG_RUN_MAIN') == 'true') |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 app = _get_piecrust_server(root_dir, |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 debug=debug_piecrust, |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
29 theme_site=theme_site, |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 sub_cache_dir=sub_cache_dir, |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
31 run_sse_check=_run_sse_check) |
552
9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
Ludovic Chabant <ludovic@chabant.com>
parents:
374
diff
changeset
|
32 |
558
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
33 # We need to do a few things to get Werkzeug to properly shutdown or |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
34 # restart while SSE responses are running. This is because Werkzeug runs |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
35 # them in background threads (because we tell it to), but those threads |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
36 # are not marked as "daemon", so when the main thread tries to exit, it |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
37 # will wait on those SSE responses to end, which will pretty much never |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
38 # happen (except for a timeout or the user closing their browser). |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
39 # |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
40 # In theory we should be using a proper async server for this kind of |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
41 # stuff, but I'd rather avoid additional dependencies on stuff that's not |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
42 # necessarily super portable. |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
43 # |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
44 # Anyway, we run the server as usual, but we intercept the `SIGINT` |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
45 # signal for when the user presses `CTRL-C`. When that happens, we set a |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
46 # flag that will make all existing SSE loops return, which will make it |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
47 # possible for the main thread to end too. |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
48 # |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
49 # We also need to do a few thing for the "reloading" feature in Werkzeug, |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
50 # see the comment down there for more info. |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
51 def _shutdown_server(): |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
52 from piecrust.serving import procloop |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
53 procloop.server_shutdown = True |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
54 |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
55 def _shutdown_server_and_raise_sigint(): |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
56 if not use_reloader or os.environ.get('WERKZEUG_RUN_MAIN') == 'true': |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
57 # We only need to shutdown the SSE requests for the process |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
58 # that actually runs them. |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
59 print("") |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
60 print("Shutting server down...") |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
61 _shutdown_server() |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
62 raise KeyboardInterrupt() |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
63 |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
64 signal.signal(signal.SIGINT, |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
65 lambda *args: _shutdown_server_and_raise_sigint()) |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
66 |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
67 try: |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
68 run_simple(host, port, app, |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
69 threaded=True, |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
70 use_debugger=use_debugger, |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
71 use_reloader=use_reloader) |
558
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
72 except SystemExit: |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
73 if os.environ.get('WERKZEUG_RUN_MAIN') == 'true': |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
74 # When using the reloader, if code has changed, the child process |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
75 # will use `sys.exit` to end and let the master process restart |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
76 # it... we need to shutdown the SSE requests otherwise it will |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
77 # not exit. |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
78 _shutdown_server() |
9ab005db2592
serve: Improve reloading and shutdown of the preview server.
Ludovic Chabant <ludovic@chabant.com>
parents:
553
diff
changeset
|
79 raise |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
80 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
81 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
82 def run_gunicorn_server(root_dir, |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
83 debug_piecrust=False, theme_site=False, |
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
84 sub_cache_dir=None, |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
85 gunicorn_options=None): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
86 from gunicorn.app.base import BaseApplication |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
87 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
88 class PieCrustGunicornApplication(BaseApplication): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
89 def __init__(self, app, options): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
90 self.app = app |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
91 self.options = options |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
92 super(PieCrustGunicornApplication, self).__init__() |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
93 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
94 def load_config(self): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
95 for k, v in self.options.items(): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
96 if k in self.cfg.settings and v is not None: |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
97 self.cfg.set(k, v) |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
98 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
99 def load(self): |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
100 return self.app |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
101 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
102 app = _get_piecrust_server(root_dir, |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
103 debug=debug_piecrust, |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
104 theme_site=theme_site, |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
105 sub_cache_dir=sub_cache_dir) |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
106 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
107 gunicorn_options = gunicorn_options or {} |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
108 app_wrapper = PieCrustGunicornApplication(app, gunicorn_options) |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
109 app_wrapper.run() |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
110 |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
111 |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
112 def _get_piecrust_server( |
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
113 root_dir, debug=False, theme_site=False, |
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
114 sub_cache_dir=None, run_sse_check=None): |
553
cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
Ludovic Chabant <ludovic@chabant.com>
parents:
552
diff
changeset
|
115 from piecrust.serving.middlewares import ( |
cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
Ludovic Chabant <ludovic@chabant.com>
parents:
552
diff
changeset
|
116 StaticResourcesMiddleware, PieCrustDebugMiddleware) |
cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
Ludovic Chabant <ludovic@chabant.com>
parents:
552
diff
changeset
|
117 from piecrust.serving.server import WsgiServer |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
118 app = WsgiServer(root_dir, debug=debug, theme_site=theme_site, |
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
119 sub_cache_dir=sub_cache_dir) |
553
cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
Ludovic Chabant <ludovic@chabant.com>
parents:
552
diff
changeset
|
120 app = StaticResourcesMiddleware(app) |
cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
Ludovic Chabant <ludovic@chabant.com>
parents:
552
diff
changeset
|
121 app = PieCrustDebugMiddleware(app, root_dir, |
663
3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
Ludovic Chabant <ludovic@chabant.com>
parents:
558
diff
changeset
|
122 theme_site=theme_site, |
553
cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
Ludovic Chabant <ludovic@chabant.com>
parents:
552
diff
changeset
|
123 sub_cache_dir=sub_cache_dir, |
cc6f3dbe3048
serve: Extract some of the server's functionality into WSGI middlewares.
Ludovic Chabant <ludovic@chabant.com>
parents:
552
diff
changeset
|
124 run_sse_check=run_sse_check) |
374
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
125 return app |
fa3ee8a8ee2d
serve: Split the server code in a couple modules inside a `serving` package.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
126 |