MCPcopy Index your code
hub / github.com/webpy/webpy / StaticMiddleware

Class StaticMiddleware

web/httpserver.py:242–262  ·  view source on GitHub ↗

WSGI middleware for serving static files.

Source from the content-addressed store, hash-verified

240
241
242class StaticMiddleware:
243 """WSGI middleware for serving static files."""
244
245 def __init__(self, app, prefix="/static/"):
246 self.app = app
247 self.prefix = prefix
248
249 def __call__(self, environ, start_response):
250 path = environ.get("PATH_INFO", "")
251 path = self.normpath(path)
252
253 if path.startswith(self.prefix):
254 return StaticApp(environ, start_response)
255 else:
256 return self.app(environ, start_response)
257
258 def normpath(self, path):
259 path2 = posixpath.normpath(unquote(path))
260 if path.endswith("/"):
261 path2 += "/"
262 return path2
263
264
265class LogMiddleware:

Callers 1

runsimpleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected