4

I have installed the Python , apache. The command line programs are working with python.

I have two virtual hosts in apache

site1.local
site2.local

WHat i want is i place file in site1 root directory and it display hello in browser

with mod_wsgl only without cgi

2 Answers2

4

In it's most simplest form..

Create a file called hello_world.wsgi with the following contents. This should be outside of your DocumentRoot so that Apache is unable to serve it up as plain text:

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]

Then configure your vhost to serve all requests beneath / from that script:

WSGIScriptAlias / <path_to_script>/hello_world.wsgi
Dan Carley
  • 25,617
  • 5
  • 53
  • 70
  • i am trying that and will let u know. Thanks for being simple and straight to point –  Jun 24 '10 at 00:44
  • Thanks buddy i finally displayed hello in browser. I am confused with one thing , i was epecting to run something like hello.py and now i am running wsgi so it means on web i can't have something like hello.py and with code in it. Where will i write my all code? –  Jun 24 '10 at 07:00
1

Have you actually tried reading the mod_wsgi documentation. That is what it is there for.

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide http://code.google.com/p/modwsgi/wiki/WhereToGetHelp

Graham Dumpleton
  • 6,090
  • 2
  • 21
  • 19