av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)Python教程:Python中實(shí)現(xiàn)WSGI的框架

1、說明

創(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)目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元五華做網(wǎng)站,已為上家服務(wù),為五華各地企業(yè)和個人服務(wù),聯(lián)系電話:18982081108

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

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的框架,希望對大家有所幫助。更多Python學(xué)習(xí)推薦:python教學(xué)

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


網(wǎng)頁題目:創(chuàng)新互聯(lián)Python教程:Python中實(shí)現(xiàn)WSGI的框架
標(biāo)題URL:http://uogjgqi.cn/article/coideoh.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流