i am trying to execute a python script in my XAMPP server but i get a blank page each time i call the script. When i try to execute it in the adress localhost/cgi-bin/script.py it works fine but when i try to execute it in htdocs it comes in blank. In my htdocs directory i have 2 files:
html file:
<!DOCTYPE html>
<html>
<body>
<form name="input" action="http://localhost/insert.PHP" method="post">
User: <input type="text" name="user" value="Obama"><br>
Password: <input type="password" name="pass">
<input type="submit" value="Submit">
</form>
</body>
</html>
insert.php file which brings .py file to execute:
<?php
$Nome = $_POST['user'];
$Password = $_POST['pass'];
echo ini_get("disable_functions");
$python = exec('C:\xampp\cgi-bin\script.py');
echo $python;
?>
finally .py file (script.py) in cgi-bin directory:
#!C:\Python27\python.exe
import cgitb
cgitb.enable()
print "Content-Type: text/html"
print
print """
<TITLE>CGI script</TITLE>
<H1> just fine !</H1>
"""
print " <p>I am a script in python! </p>"
So i type User and password, it redirects to insert.php and i get a blank page. Thanks!