Wednesday, May 23, 2012

Post JSON to Python CGI

I am looking to post JSON sent by any standard library such as 'JQUERY' using the standard.



$.ajax() post routine with my JSON.



can you tell me if on the page I post to ("saveList.py") this code is correct that will get the resultant json and then return the response as successful.



cheers, I've only ever worked with Django and now raw cgi so im slightly confused.



#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys
import json

def get():
result = {'success':'true','message':'The Command Completed Successfully'}
data = sys.stdin.read()
myjson = json.loads(data)

self.response.out.write(str(result))




No comments:

Post a Comment