Know what you're getting – Unlike many sites, all our code is clearly licensed.
Join Siafoo Now
or
Learn More
Pylons Middleware to Strip a Trailing Slash
0
Updated over 4 years ago (03 Apr 2009 at 11:36 AM)
recent activity
| In Brief | You can use this middleware to strip a trailing slash from the request, since the new Routes doesn't seem to like them. You should probably do this at the very bottom of your middleware.py, before it returns, so this will be the first middleware the request gets to:... more |
| Language | Python |
# 's
1class StripTrailingSlash(object):
2 def __init__(self, app):
3 self.app = app
4
5 def __call__(self, environ, start_response):
6 environ['PATH_INFO'] = environ.get('PATH_INFO', '').rstrip('/')
7 return self.app(environ, start_response)
You can use this middleware to strip a trailing slash from the request, since the new Routes doesn't seem to like them. You should probably do this at the very bottom of your middleware.py, before it returns, so this will be the first middleware the request gets to:
# 's
1app = StripTrailingSlash(app)
Add a Comment