Debian Codegraph @

docs/source/development.rst

raw
1 .. _development:
2
3 Developing Pecan Applications Locally
4 =====================================
5
6 .. include:: reload.rst
7 :start-after: #reload
8
9 Debugging Pecan Applications
10 ----------------------------
11
12 Pecan comes with simple debugging middleware for helping diagnose problems
13 in your applications. To enable the debugging middleware, simply set the
14 ``debug`` flag to ``True`` in your configuration file::
15
16 app = {
17 ...
18 'debug': True,
19 ...
20 }
21
22 Once enabled, the middleware will automatically catch exceptions raised by your
23 application and display the Python stack trace and WSGI environment in your
24 browser when runtime exceptions are raised.
25
26 To improve debugging, including support for an interactive browser-based
27 console, Pecan makes use of the Python `backlash
28 <https://pypi.python.org/pypi/backlash>` library. You’ll need to install it
29 for development use before continuing::
30
31 $ pip install backlash
32 Downloading/unpacking backlash
33 ...
34 Successfully installed backlash
35
36
37 Serving Static Files
38 --------------------
39
40 Pecan comes with simple file serving middleware for serving CSS, Javascript,
41 images, and other static files. You can configure it by ensuring that the
42 following options are specified in your configuration file:
43
44 ::
45
46 app = {
47 ...
48 'debug': True,
49 'static_root': '%(confdir)/public
50 }
51
52 where ``static_root`` is an absolute pathname to the directory in which your
53 static files live. For convenience, the path may include the ``%(confdir)``
54 variable, which Pecan will substitute with the absolute path of your
55 configuration file at runtime.
56
57 .. note::
58
59 In production, ``app.debug`` should *never* be set to ``True``, so you'll
60 need to serve your static files via your production web server.