關於如何下載uwsgi的python接口網路上已經有很多方法,這篇只記錄我遇到的問題及解法
我創建了一個稱為server.py的python 文件
如下
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
很明顯功能只有在網頁上顯示Hello World,但我的網頁什麼都沒顯示連錯誤也沒有
解決方法:
把output = 'Hello World!'加b,output = b'Hello World!'就可以了,原因為
Python 2 把字串編為 bytes 类型,而python3則編為unicode碼,而我是使用pyython3所以要先把字串轉為byte才能顯示
請先 登入 以發表留言。