Hi am a noob working with Apache, mod_wsgi and python.

Below is some sample code on the internet that will return "Hello World!" when i go to my local server:

www.localhost.com/py

note:

I do have

WSGIScriptAlias /py "C:/Users/user/site/handler.py"

in my httpd.conf

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]

can anyone give me a run down of how this code works differently then if i were to just try to run the following the pyhton shell:

def main()
    print "Hello World!"
    return 0

My goal is to adapt some code that runs in the python shell to run on my server with the same function, but when I try to modify most things i get Internal Server Errors (ie: adding import cgi) or the link to the code breaks...

Something to add, my server's error log displays this:
[Tue Nov 02 23:10:11 2010] [notice] Parent: Received restart signal -- Restarting the server.
[Tue Nov 02 23:10:11 2010] [notice] Child 5224: Exit event signaled. Child process is ending.
[Tue Nov 02 23:10:11 2010] [warn] mod_wsgi: Compiled for Python/2.6.2.
[Tue Nov 02 23:10:11 2010] [warn] mod_wsgi: Runtime using Python/2.6.1.
[Tue Nov 02 23:10:11 2010] [notice] Apache/2.2.17 (Win32) mod_wsgi/3.3 Python/2.6.1 PHP/5.2.14 configured -- resuming normal operations
[Tue Nov 02 23:10:11 2010] [notice] Server built: Oct 18 2010 01:58:12
[Tue Nov 02 23:10:11 2010] [notice] Parent: Created child process 4508
[Tue Nov 02 23:10:11 2010] [warn] mod_wsgi: Compiled for Python/2.6.2.
[Tue Nov 02 23:10:11 2010] [warn] mod_wsgi: Runtime using Python/2.6.1.
[Tue Nov 02 23:10:11 2010] [notice] Child 4508: Child process is running
[Tue Nov 02 23:10:12 2010] [notice] Child 4508: Acquired the start mutex.
[Tue Nov 02 23:10:12 2010] [notice] Child 4508: Starting 64 worker threads.
[Tue Nov 02 23:10:12 2010] [notice] Child 5224: Released the start mutex
[Tue Nov 02 23:10:13 2010] [notice] Child 5224: All worker threads have exited.
[Tue Nov 02 23:10:13 2010] [notice] Child 4508: Starting thread to listen on port 80.
[Tue Nov 02 23:10:13 2010] [notice] Child 5224: Child process is exiting

And though Hello World prints to the screen in chrome, i still see 500 Internal Server Error in the tab title

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.