json2.py 375 B

1234567891011
  1. from WebKit.HTTPContent import HTTPContent
  2. import json
  3. class json2(HTTPContent):
  4. def defaultAction(self):
  5. self.response().clearHeaders()
  6. self.response()._headers["Content-Type"] = "application/json"
  7. output = json.dumps({"message": "Hello, World!"})
  8. self.response()._headers["Content-Length"] = len(output)
  9. self.write(output)