關於如何下載uwsgipython接口網路上已經有很多方法,這篇只記錄我遇到的問題及解法

我創建了一個稱為server.pypython 文件

如下

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!'boutput = b'Hello World!'就可以了,原因為

Python 2 把字串編為 bytes 类型,而python3則編為unicode碼,而我是使用pyython3所以要先把字串轉為byte才能顯示
 

創作者介紹
創作者 dodo的部落格 的頭像
dodo

dodo的部落格

dodo 發表在 痞客邦 留言(0) 人氣( 2 )