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 inc开发者_如何学JAVAoming 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.
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())
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.
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
精彩评论