0

I was trying to learn how to execute python code using Apache. Having gone through various tutorials, I configured my conf file as follows to allow python code execution.

000-default.conf:

enter image description here

My python program, hello.py is following:

enter image description here

The program is put in directory /var/www/html/cgi-bin/. After Setting all this, When I goto address of file (www.domainname.com/cgi-bin/hello.py), I am met with following error.

enter image description here

How to resolve this error and get my code running?

1 Answer 1

1

You need a handler in your python file.

from mod_python import apache

def handler(req):

    req.content_type = "text/plain"
    req.write("Hello World!")

    return apache.OK
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.