Sean W.
Sean W.

Reputation: 5142

How can one process POST requests with a basic Python CGI script on Apache?

I am building a simple python CGI script to work with Twilio. Right now, it only outputs some simple XML, but I would like it to be able to process and respond to POST requests (to get thinks like incoming caller ID). Eventually, I will use a full web application framework, like Django; but, for now, I just want a simple service which can interact with Twilio. What is the simplest way to do this?

Thanks in advance.

Upvotes: 1

Views: 2742

Answers (3)

Hosemeyer
Hosemeyer

Reputation: 1274

Is there a reason why you aren't just using the Twilio python module? It trivializes interacting with Twilio.

There are a few examples provided there, the rest you should easily be able to figure out by looking over the documentation provided on Twilio's website.

https://www.twilio.com/docs/python/install

Upvotes: 1

6502
6502

Reputation: 114481

I found cherrypy very easy to use. You can get argument passing (including support for POST file upload) but not not much else, i.e. you choose whatever template, if any, you want to use, whatever DB ...

Here is the helloworld example from their homepage...

import cherrypy

class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())

Upvotes: 5

Andrea Spadaccini
Andrea Spadaccini

Reputation: 12651

You could try the cgi module in the standard library.

I suggest you to move on to the web.py framework. And then, if you need, to use django or other web frameworks.

Upvotes: 2

Related Questions