Python for the web

python

Solution

The answer you're probably looking for is `mod_wsgi` with Apache or `uwsgi` with nginx.

Using these you can run any application you like.

For example should apache be configured for it `myapp.wsgi` looks as follows: (per here: http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide)

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

This is just about the minimum requirement to return a web page.

Problem

I have read that Python can be used for web applications. Yet I wonder how form variables are passed to Python scripts and how to, so to speak, "connect" Python to an Apache server so that it serves dynamic web pages, the same way PHP so easily does. How is this done and is it better than using PHP?

Original source

Related problems