Reputation: 21
I'm working with Django and Piston and I created the following Handler:
from piston.handler import BaseHandler
import datetime
import json
class NotificationHandler( BaseHandler ):
allowed_methods = ('POST',)
def create( self, request, token ):
return json.dumps( datetime.datetime.now() )
When making a request to this handler I'm getting an html page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>something</title>
<META name="description" content="something"><META name="keywords" content="something">
</head>
<frameset rows="100%,*" border="0">
<frame src="http://something.com/pay/notify/345345/" frameborder="0" />
<frame frameborder="0" noresize />
</frameset>
<!-- pageok -->
<!-- 03 -->
<!-- -->
</html>
It looks like it's wripping the call into a frameset. However I would expect to get something like:
"2012-01-11 00:17:24"
I'm using apache with mod_wsgi. When running the project locally from the server provided by the PyCharm IDE I get the expected json value.
Not sure why I'm getting different results since I'm using the same script to make the request (with the same headers).
What would make Piston return an HTML page instead of a raw json string? May it be a header?
Upvotes: 1
Views: 349
Reputation: 58533
Consider using the WSGI application wrapper described in:
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response
to capture both input and output for the request.
This will allow you to verify whether Django gets called, plus what is returned into mod_wsgi and so determine if issue is within Django of whether Apache caching or something else if causing issue after application returns response.
Upvotes: 0
Reputation: 43096
Check your Apache configuration and make sure that the function is called (raising an exception like proposed by David Robinson).
Upvotes: 0