-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start tearing things apart to make a proper wsgi enabled version of w…
…scompose/pinwin
- Loading branch information
1 parent
abf1b2c
commit a2bc914
Showing
3 changed files
with
268 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import urlparse | ||
import wscompose | ||
|
||
def application(environ, start_response): | ||
|
||
# path_info = environ.get('PATH_INFO', None) | ||
|
||
query_string = environ.get('QUERY_STRING', None) | ||
params = urlparse.parse_qs(query_string) | ||
|
||
ws = wscompose.wscompose() | ||
|
||
try: | ||
|
||
if len(params.keys()) == 0: | ||
|
||
status = '200 OK' | ||
content_type = 'text/plain' | ||
data = ws.help() | ||
|
||
else: | ||
|
||
ws.load_ctx(params) | ||
|
||
status = '200 OK' | ||
content_type = 'text/plain' | ||
data = str(params) | ||
|
||
except Exception, e: | ||
|
||
print >> environ['wsgi.errors'], "[gunistache] failed to handle request:" + str(e) | ||
status = '500 SERVER ERROR' | ||
content_type = 'text/plain' | ||
data = str(e) | ||
|
||
# mod_wsgi hates unicode apparently | ||
# so make sure everything is a str. | ||
|
||
response_headers = [ | ||
('Content-type', str(content_type)), | ||
('Content-Length', str(len(data))) | ||
] | ||
|
||
start_response(status, response_headers) | ||
return iter([data]) |
Oops, something went wrong.