日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:Python中實(shí)現(xiàn)WSGI的框架

1、說(shuō)明

創(chuàng)新互聯(lián)成立與2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元五華做網(wǎng)站,已為上家服務(wù),為五華各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108

Application類對(duì)WSGI又做了一層簡(jiǎn)單的封裝,由于上面說(shuō)過(guò)WSGI函數(shù)返回的是一個(gè)可以迭代對(duì)象,所以需要實(shí)現(xiàn)一個(gè)__iter__方法,里面控制了客戶端的請(qǐng)求路由并且返回不同的輸出。

2、實(shí)例

from wsgiref.simple_server import make_server
 
class Application(object):
 
    def __init__(self, environ, start_response):
        self.start_response = start_response
        self.path = environ['PATH_INFO']
 
    def __iter__(self):
        if self.path == '/':
            status = '200 OK'
            response_headers = [('Content-type', 'text/html')]
            self.start_response(status, esponse_headers)
            yield '

Hello,World!

'.encode('utf-8')           elif self.path == '/wsgi':             status = '200 OK'             response_headers = [('Content-type', 'text/html')]             self.start_response(status, response_headers)             yield '

Hello,WSGI!

'.encode('utf-8')           else:             status = '404 NOT FOUND'             response_headers = [('Content-type', 'text/html')]             self.start_response(status, response_headers)             yield '

404 NOT FOUND

'.encode('utf-8')   if __name__ == "__main__":     app = make_server('127.0.0.1', 8000, Application)     print('Serving HTTP on port 8000...')     app.serve_forever()

以上就是python中實(shí)現(xiàn)WSGI的框架,希望對(duì)大家有所幫助。更多Python學(xué)習(xí)推薦:python教學(xué)

本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。


網(wǎng)頁(yè)題目:創(chuàng)新互聯(lián)Python教程:Python中實(shí)現(xiàn)WSGI的框架
網(wǎng)頁(yè)地址:http://www.dlmjj.cn/article/coideoh.html