Apacheで同じ.pyファイルを実行することはできません。

Apacheで同じ.pyファイルを実行することはできません。

PiにApache Webサーバーを設定しました。すべての権限を設定し、「hello world」Pythonプログラムを実行できます。

JavaScript:

function hellowWorld(){          
     $.ajax({               
            url: "cgi/helloworld.py",           
            dataType: "json",       
            type: "post",           
            error: ajaxError,           
            success: function(json){  
                    console.log(json.msg);
            }
     });        
}

Python:

#!/usr/bin/python3

import json
import cgi

header=0

def hw():
        jData={
            "msg":"hello world"
        }
        return ("Content-type: application/json\r\n\r\n"+json.dumps(jData)) 
        

print( hw() )

その後、helloworld.pyをdefaults.pyという名前の新しいファイルにコピーしてテストしましたが、エラー500が発生しました。

function loadDefaults(){             
     $.ajax({               
            url: "cgi/defaults.py",             
            dataType: "json",       
            type: "post",           
            error: ajaxError,           
            success: function(json){                        
                    console.log(json.msg);
            }
     });        
}

私が知る限り、両方の.pyファイルは同じ権限を持っています。

264069 -rwxr-xr-x 1 root root 208 Sep 27 11:00 defaults.py
264068 -rwxr-xr-x 1 root root 193 Sep 27 11:00 helloworld.py

なぜ1つは実行され、もう1つは実行されないのですか?

ベストアンサー1

おすすめ記事