blob: 118c225389afcb01def3f81cf6766f3ff65179d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
from urllib import unquote
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 = unquote(environ['REQUEST_URI']).split('?', 1)[0]
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)
|