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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
【Python】WSGI簡單Web服務(wù)器,處理GET和POST請求-創(chuàng)新互聯(lián)
【Python】WSGI簡單Web服務(wù)器,處理GET和POST請求
    • Python服務(wù)器代碼
    • 靜態(tài)HTML文件代碼

創(chuàng)新互聯(lián)建站成立與2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站設(shè)計制作、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元珠暉做網(wǎng)站,已為上家服務(wù),為珠暉各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792Python服務(wù)器代碼
"""
Small wsgiref based web server. Takes a path to serve from and an
optional port number (defaults to 8000), then tries to serve files.
MIME types are guessed from the file names, 404 errors are raised
if the file is not found.
"""
import mimetypes
import os
import sys
from wsgiref import simple_server, util
from urllib.parse import parse_qs


def app(environ, respond):
    get_query_ =environ['QUERY_STRING']
    post_query_=environ["wsgi.input"].read(int(e)).decode("utf-8", 'ignore') if (e:=environ.get("CONTENT_LENGTH")) else None
    get_query =parse_qs(get_query_)
    post_query=parse_qs(post_query_)

    print("REQUEST_METHOD: "+environ['REQUEST_METHOD'])
    print("GET : ",(get_query))
    print("POST: ",(post_query))

    if(environ["PATH_INFO"].startswith(r"/post")):
        respond("200 OK", [("Content-Type", "text/html; charset=utf-8")])
        message=("Welcome, "+e[0]+" !") if (e:=post_query.get('username')) else "Welcome ! "
        html = ''' Post page   %s  
                Post Data:
%s
Path:
%s
''' %( message, str(post_query), environ["PATH_INFO"]) return [html.encode("utf-8")] else: # Get the file name and MIME type fn = os.path.join(path,"res", environ["PATH_INFO"][1:]) if "." not in fn.split(os.path.sep)[-1]: fn = os.path.join(fn, "index.html") mime_type = mimetypes.guess_type(fn)[0] # Return 200 OK if file exists, otherwise 404 Not Found if os.path.exists(fn): respond("200 OK", [("Content-Type", mime_type)]) return util.FileWrapper(open(fn, "rb")) else: respond("404 Not Found", [("Content-Type", "text/plain")]) return [b"not found"] if __name__ == "__main__": # Get the path and port from command-line arguments path = sys.argv[1] if len(sys.argv) >1 else os.getcwd() port = int(sys.argv[2]) if len(sys.argv) >2 else 8000 # Make and start the server until control-c httpd = simple_server.make_server("", port, app) print(f"Serving {path} on port {port}, control-C to stop") try: httpd.serve_forever() except KeyboardInterrupt: print("Shutting down.") httpd.server_close()
靜態(tài)HTML文件代碼
?????
username:
password:
文本框:
download

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧


分享文章:【Python】WSGI簡單Web服務(wù)器,處理GET和POST請求-創(chuàng)新互聯(lián)
地址分享:http://www.dlmjj.cn/article/cdcjgg.html