1

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.

3 Answers 3

5

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())
Sign up to request clarification or add additional context in comments.

1 Comment

cherrypy looks very nice. If it weren't for the fact that I need to use the django admin interface and a few other pre-made apps, I would strongly consider using it for this project. However, it looks like it would come in handy for prototyping and smaller projects.
2

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.

1 Comment

Thanks. I used the FieldStorage class in the cgi module to get myself acquainted with the twilio API. I am now moving onto Django.
1

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

1 Comment

Yes, I am using the twilio module to talk to Twilio API and generate TwiML; however, the twillio module does not process GET or POST requests for you. Rather, it expects your application to deal with these requests, and call the twilio methods when needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.