0
在我的Virtualenv創建了「Hello,World!」 web應用程序來測試Gunicorn。編輯後網頁不變
這是我使用的代碼:
def app(environ, start_response):
data = "Hello, World!\n"
start_response("200 OK", [
("Content-Type", "text/plain"),
("Content-Length", str(len(data)))
])
return iter([data])
當我訪問(http://127.0.0.1:8000),它清楚地輸出:「你好,世界」它應該這樣做。但是,一旦我將數據字符串更改爲:data = "This is an edit!"
並刷新瀏覽器,它仍會顯示:「Hello,World!」。我的結論;看起來我必須在每次更改代碼後重新啓動Gunicorn,這在開發環境中工作時真的很痛苦。
有沒有辦法解決這個問題?
當我執行cat命令它正確地顯示代碼:
(web)[email protected]:~/Envs/web/myapp$ cat myapp.py
def app(environ, start_response):
data = "This is an edit!"
start_response("200 OK", [
("Content-Type", "text/plain"),
("Content-Length", str(len(data)))
])
return iter([data])
我用這個命令來啓動服務器:gunicorn -w 4 myapp:app
mod_wsgi不太可能用於gunicorn。檢查gunicorn是否有其自己的開發模式。 – 2012-07-12 17:35:50