Skip to content

Instantly share code, notes, and snippets.

@steve-ross
Created September 23, 2011 19:05
Show Gist options
  • Save steve-ross/1238181 to your computer and use it in GitHub Desktop.
Save steve-ross/1238181 to your computer and use it in GitHub Desktop.
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