开发者

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

开发者 https://www.devze.com 2023-02-10 01:08 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消