Disabling the static file middleware if `conf.app.debug` is True.
This is an effort to prevent people from using the static file middleware in production (instead of a proxy server, like nginx).
This commit is contained in:
@@ -8,7 +8,7 @@ from middleware.debug import DebugMiddleware
|
||||
from middleware.errordocument import ErrorDocumentMiddleware
|
||||
from middleware.logger import TransLogger
|
||||
from middleware.recursive import RecursiveMiddleware
|
||||
from middleware.static import SharedDataMiddleware
|
||||
from middleware.static import StaticFileMiddleware
|
||||
|
||||
from configuration import set_config
|
||||
from configuration import _runtime_conf as conf
|
||||
@@ -48,9 +48,9 @@ def make_app(root, static_root=None, debug=False, errorcfg={},
|
||||
if debug:
|
||||
app = DebugMiddleware(app)
|
||||
|
||||
# Support for serving static files (for development convenience)
|
||||
if static_root:
|
||||
app = SharedDataMiddleware(app, static_root)
|
||||
# Support for serving static files (for development convenience)
|
||||
if static_root:
|
||||
app = StaticFileMiddleware(app, static_root)
|
||||
|
||||
# Support for simple Apache-style logs
|
||||
if isinstance(logging, dict) or logging == True:
|
||||
|
||||
@@ -88,7 +88,7 @@ def http_date(timestamp=None):
|
||||
return _dump_date(timestamp, ' ')
|
||||
|
||||
|
||||
class SharedDataMiddleware(object):
|
||||
class StaticFileMiddleware(object):
|
||||
"""A WSGI middleware that provides static content for development
|
||||
environments.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from unittest import TestCase
|
||||
from pecan.middleware.static import (SharedDataMiddleware, FileWrapper,
|
||||
from pecan.middleware.static import (StaticFileMiddleware, FileWrapper,
|
||||
_dump_date)
|
||||
|
||||
import os
|
||||
@@ -13,7 +13,7 @@ class TestStaticFileMiddleware(TestCase):
|
||||
start_response('200 OK', response_headers)
|
||||
return ['Hello world!\n']
|
||||
|
||||
self.app = SharedDataMiddleware(
|
||||
self.app = StaticFileMiddleware(
|
||||
app, os.path.dirname(__file__)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user