私は単にPythonサーバーを作成しました:
python -m SimpleHTTPServer
私は.htaccessを持っていました(Pythonサーバーで役立つかどうかはわかりません):
AddHandler cgi-script .py
Options +ExecCGI
今、私は簡単な python スクリプトを書いています:
#!/usr/bin/python
import cgitb
cgitb.enable()
print 'Content-type: text/html'
print '''
<html>
<head>
<title>My website</title>
</head>
<body>
<p>Here I am</p>
</body>
</html>
'''
test.py (スクリプトの名前) を実行ファイルにします。
chmod +x test.py
私は次のアドレスで Firefox を起動しています: (http : //) 0.0.0.0:8000/test.py
問題、スクリプトが実行されません... Web ページにコードが表示されます... サーバー エラーは次のとおりです。
localhost - - [25/Oct/2012 10:47:12] "GET / HTTP/1.1" 200 -
localhost - - [25/Oct/2012 10:47:13] code 404, message File not found
localhost - - [25/Oct/2012 10:47:13] "GET /favicon.ico HTTP/1.1" 404 -
Pythonコードの実行を簡単に管理するにはどうすればよいですか? 次のようなPythonスクリプトを実行するためにPythonサーバーに書き込むことは可能ですか?
import BaseHTTPServer
import CGIHTTPServer
httpd = BaseHTTPServer.HTTPServer(\
('localhost', 8123), \
CGIHTTPServer.CGIHTTPRequestHandler)
### here some code to say, hey please execute python script on the webserver... ;-)
httpd.serve_forever()
または、他の何か...