I have a couple of app engine urls that return pure JSON and this works fine in production. However, when I run the app locally (dev_appserver.py), it spits out a few additional lines in the response before the actual json string, like so:
Status: 200
content-type: application/json; charset=utf-8
Cache-Control: no-cache
Content-Length: 103480
[{"json":"here"}]
The lines before the actual json cause my javascript client to choke, is there a way to prevent the dev_appserver from including those lines?
edit: as requested, here’s the handler:
class GetEvents(webapp2.RequestHandler):
"""
returns json object with events for a given date (yyyy-mm-dd format)
"""
def get(self):
start_date = self.request.get("start")
use_cache = self.request.get("use_cache")
# check if we have this date in cache
output = memcache.get(start_date)
if output == None or use_cache == "no":
# query datastore
# make dictionary
# store in cache
self.response.headers['Content-Type'] = "application/json"
return self.response.out.write(output)
Cheers,
the hoff
ok, figure it out:
somewhere in the handler, I had a print statement, which seems to cause these extra lines to show up. Leaving this is here reference.