我有大量的python腳本(主要是爲了方便)生成html輸出,所以當然我想使用一個非常簡單的設置在我當前的測試環境中託管腳本。在Django,Flask,web2py或其他的項目中設置項目,對於我需要的每一個愚蠢的事情來說,太麻煩了,我只想編寫一個.py並瀏覽它,而不用配置任何其他內容,就像使用php一樣。簡單的nginx + uWSGI設置問題
我一直是這樣掙扎了幾天,因爲我不知道什麼是錯的,所以我就後我與配置文件當前的嘗試:
nginx的:
location ~ \.py$ {
uwsgi_pass unix:///path/to/socket;
uwsgi_param SCRIPT_NAME $uri;
include uwsgi_params;
}
uWSGI
[uwsgi]
plugins = python3
py-auto-reload = 1 #So I dont have to reload the service every time
test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return b"Hello World"
我在nginx的和uwsgi配置很多很多很多的變化,但我總是得到:
uWSGI錯誤
沒有找到Python應用程序
和日誌總是顯示像這樣的東西:
[pid: 10423|app: -1|req: -1/10] 10.0.20.101() {42 vars in 675 bytes} [Sun Oct 6 08:25:51 2013] GET /test.py => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
-
Sun Oct 6 08:26:44 2013 - unable to load app 0 (mountpoint='/var/www/test.py') (callable not found or import error)
[pid: 10423|app: -1|req: -1/12] 10.0.20.101() {44 vars in 707 bytes} [Sun Oct 6 08:26:44 2013] GET /test.py => generated 48 bytes in 0 msecs (H
TTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
-
Sun Oct 6 07:22:36 2013 - unable to load app 0 (mountpoint='/test.py') (callable not found or import error)
[pid: 10423|app: -1|req: -1/12] 10.0.20.101() {44 vars in 707 bytes} [Sun Oct 6 08:26:44 2013] GET /test.py => generated 48 bytes in 0 msecs (H
TTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)