I'm using xampp installed on Ubuntu.
What I did: [edited the following line in httpd.conf] AddHandler cgi-script .cgi .pl .asp .py
My python script present in htdocs is:
#!/usr/bin/python3
import cgitb
print("Content-Type: text/html;charset=utf-8\n")
print ("Hello Python Web Browser!! This is cool!!")
Output result is: End of script output before headers: sample.py
1 Answer 1
Looking at error log from comments, the file does not have correct permissions to execute. Simply do
$ sudo chmod -R 777 /opt/lampp/htdocs/portScanner
WARNING: It is really a bad idea to change permissions to 777 on a webserver, alternatively you could try changing ownership of this directory to the apache user which is usually www-data in ubuntu
$ sudo chwon -R www-data /opt/lampp/htdocs/portScanner
answered Apr 16, 2020 at 19:41
MohitC
4,8112 gold badges38 silver badges60 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default
/usr/bin/python3exists and is executable by others