Created
September 23, 2011 19:05
-
-
Save steve-ross/1238181 to your computer and use it in GitHub Desktop.
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
class reader: | |
def __init__(self): | |
self.s = str | |
def main(self, part='body'): | |
for req in self.requests(): | |
#self.body = {'response': req['body']} | |
return req[part] | |
#self.respond(data={"response": req['body']}) | |
def requests(self): | |
# 'for line in sys.stdin' won't work here | |
line = sys.stdin.readline() | |
while line: | |
yield json.loads(line) | |
line = sys.stdin.readline() | |
def respond(self, code=200, data={}, headers={}): | |
sys.stdout.write("%s\n" % json.dumps({"code": code, "json": data, "headers": headers})) | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment