日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

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

1、說(shuō)明

創(chuàng)新互聯(lián)成立與2013年,是專(zhuān)業(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)系電話(huà):18982081108

Application類(lèi)對(duì)WSGI又做了一層簡(jiǎn)單的封裝,由于上面說(shuō)過(guò)WSGI函數(shù)返回的是一個(gè)可以迭代對(duì)象,所以需要實(shí)現(xiàn)一個(gè)__iter__方法,里面控制了客戶(hù)端的請(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電腦。


新聞名稱(chēng):創(chuàng)新互聯(lián)Python教程:Python中實(shí)現(xiàn)WSGI的框架
分享網(wǎng)址:http://m.5511xx.com/article/coideoh.html