trying to create simple py script
Ifthikhan Nazeem
iftecan2000 at gmail.com
Fri Aug 10 03:49:54 EDT 2012
I have been using Flask for a while and it's been a positive experience so
far. It's simplicity helps you to get things done faster.
On Fri, Aug 10, 2012 at 8:35 AM, Lutz Horn <lutz.horn at fastmail.fm> wrote:
> Hi Smaran,
>
> Am Do, 9. Aug 2012, um 23:52, schrieb Smaran Harihar:
> > I am trying to create a simple cgi-script to receive a Ajax
> > call, manipulate the string received and send it back as JSON.
>
> I can recommend bottle. The following example manipulates a JSON request
> body and returns it. That is *much* easier than using CGI.
>
> #!/usr/bin/env python
>
> from bottle import request, post, run
>
> @post('/hello')
> def index():
> if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
> body = request.json
> body["baz"] = "qux"
> return body
> else:
> return 'This is a normal HTTP Post request.'
>
> run(host='localhost', port=8080)
>
> Lutz
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120810/4394c116/attachment.html>
More information about the Python-list
mailing list