sambaを経由して実行可能ファイルのCGIファイルを設置した際に、CGIとして実行可能なownershipと
permissionを設定する方法については、サービス (daemon)
インストール の samba とACL設定を参照。
sambaの設定だけで十分なはずだが、ACLの継承 (inherit)
を利用すると、柔軟な設定が可能。
デバッグ情報の見方
import cgitb
cgitb.enable()
import traceback
def handle_exception(exc_type, exc_value, exc_tb):
"""例外をHTML形式で出力"""
print("Content-Type: text/html\n")
print("<html><body>")
print("<h2>Error:</h2>")
print("<pre>")
traceback.print_exception(exc_type, exc_value, exc_tb, file=sys.stdout)
print("</pre>")
print("</body></html>")
# エラーハンドラを設定
sys.excepthook = handle_exception
開発・デバッグ手順
python hogehoge.py
> ./hogehoge.py
python hogehoge.py action=getFiles user=user password=pw
python query2cli.py
python http_server_me.py
python debug_API.py 2 http://server/cgi-bin/cgi.py
action=get_info atom_name=Na
など。2は、query
parameterをGETで渡す場合。1は、http://server/action/の形のendopointを渡す場合、3はformでPOSTする場合に対応。
Obsolete:
> python query2cgi.py
Internal Server Errorが出る場合
以下の手順でエラーが無いかを確認する。