summaryrefslogtreecommitdiff
path: root/fixers.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--fixers.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/fixers.py b/fixers.py
new file mode 100644
index 0000000..deded63
--- /dev/null
+++ b/fixers.py
@@ -0,0 +1,22 @@
+from werkzeug.wrappers import BaseResponse as Response
+
+class ScriptNameFixer(object):
+ """Sets SCRIPT_NAME from REQUEST_URI."""
+
+ def __init__ (self, app):
+ self.app = app
+
+ def __call__ (self, environ, start_response):
+ uri = environ["REQUEST_URI"]
+ path = environ["PATH_INFO"]
+
+ if uri.endswith(path):
+ environ["SCRIPT_NAME"] = uri[:-len(path)]
+
+ return self.app(environ, start_response)
+
+def EnvironApp(environ, start_response):
+ """Returns the WSGI environment as response."""
+
+ r = Response(str(environ))
+ return r(environ, start_response)