国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

http post協(xié)議發(fā)送本地壓縮數(shù)據(jù)到服務(wù)器

這篇具有很好參考價值的文章主要介紹了http post協(xié)議發(fā)送本地壓縮數(shù)據(jù)到服務(wù)器。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

1.客戶端程序

import requests
import os
# 指定服務(wù)器的URL
url = "http://192.168.1.9:8000/upload"

# 壓縮包文件路徑
folder_name = "upload"
file_name = "test.7z"
headers = {
    'Folder-Name': folder_name,
    'File-Name': file_name
}
# 發(fā)送POST請求,并將壓縮包作為文件上傳
with open(file_name, 'rb') as file:
    response = requests.post(url, data=file,headers=headers)
# 檢查響應(yīng)狀態(tài)碼
if response.status_code == 200:
    print("文件上傳成功!")
else:
    print("文件上傳失?。?)
os.system('pause')

http post協(xié)議發(fā)送本地壓縮數(shù)據(jù)到服務(wù)器,http,服務(wù)器,網(wǎng)絡(luò)協(xié)議
http post協(xié)議發(fā)送本地壓縮數(shù)據(jù)到服務(wù)器,http,服務(wù)器,網(wǎng)絡(luò)協(xié)議

2.服務(wù)端程序

from http.server import BaseHTTPRequestHandler, HTTPServer
import os
# Define the request handler class
class MyRequestHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        # Send response status code
        self.send_response(200)

        # Send headers
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        path = self.path
        if path == '/':
            response_content = b'Hello, world!'
        elif path == '/about':
            response_content = b'This is the about page.'
        else:
            response_content = b'Page not found.'

        # Send response content
        self.wfile.write(response_content)
    def do_POST(self):
        client_address = self.client_address[0]
        client_port = self.client_address[1]

        print("client from:{}:{}".format(client_address,client_port))
        path = self.path
        print(path)
        if path == '/upload':

            content_length = int(self.headers['Content-Length'])
            print(self.headers)
            filename = self.headers.get('File-Name')
            foldname = self.headers.get('Folder-Name')
            #print(filename)
            #print(foldname)
            # 如果目錄不存在,創(chuàng)建目錄
            os.makedirs(foldname, exist_ok=True)
            filename = os.path.join(foldname, filename)
            print(filename)
            # 讀取請求體中的文件數(shù)據(jù)
            file_data = self.rfile.read(content_length)
            # # 保存文件
            with open(filename, 'wb') as file:
                file.write(file_data)
            # 發(fā)送響應(yīng)
            self.send_response(200)
            self.end_headers()
            self.wfile.write(b'File received and saved.')
        else:
            self.send_response(404)
            self.end_headers()
# Specify the server address and port
host = '192.168.1.9'
port = 8000

# Create an HTTP server instance
server = HTTPServer((host, port), MyRequestHandler)
print("Server started on {}:{}".format(host,port))

# Start the server and keep it running until interrupted
server.serve_forever()

http post協(xié)議發(fā)送本地壓縮數(shù)據(jù)到服務(wù)器,http,服務(wù)器,網(wǎng)絡(luò)協(xié)議
http post協(xié)議發(fā)送本地壓縮數(shù)據(jù)到服務(wù)器,http,服務(wù)器,網(wǎng)絡(luò)協(xié)議文章來源地址http://www.zghlxwxcb.cn/news/detail-722372.html

到了這里,關(guān)于http post協(xié)議發(fā)送本地壓縮數(shù)據(jù)到服務(wù)器的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • java http get post 和 發(fā)送json數(shù)據(jù)請求

    java http get post 和 發(fā)送json數(shù)據(jù)請求

    瀏覽器請求效果 ? ? ? main調(diào)用 ?

    2024年02月16日
    瀏覽(32)
  • HTTP POST請求發(fā)送form-data格式的數(shù)據(jù)

    發(fā)送請求給 第三方服務(wù)的接口 ,且請求報文格式為 multipart/form-data 的數(shù)據(jù)。支持復(fù)雜類型的參數(shù),包含文件類型 4.1.1、 依賴包 4.1.1、 實(shí)現(xiàn)

    2024年02月12日
    瀏覽(21)
  • C# 使用Http Post方式發(fā)送Json數(shù)據(jù),只需二步。

    一.先在工程增加 RestClient.cs類 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; using System.Web; namespace CM2.CentreWin { class RestClient { private System.Net.CookieContainer Cookies = new System.Net.CookieContainer(); priv

    2024年02月09日
    瀏覽(18)
  • 服務(wù)器發(fā)送http請求

    1、發(fā)送GET請求 curl localhost:9009/setCreateDataItem?a=1b=nihao 2、發(fā)送POST請求 3、發(fā)送json格式請求: 其中, -H 代表header頭, -X 是指定什么類型請求(POST/GET/HEAD/DELETE/PUT/PATCH), -d 代表傳輸什么數(shù)據(jù)。這幾個是最常用的。 查看所有curl命令: man curl或者curl -h 請求頭:H,A,e 響應(yīng)頭:I,i,D

    2024年01月25日
    瀏覽(17)
  • QT實(shí)現(xiàn)客戶端服務(wù)器HTTP(get請求、post請求)

    QT實(shí)現(xiàn)客戶端服務(wù)器HTTP(get請求、post請求)

    服務(wù)器代碼如下: QtHttpForS.h QtHttpForS.cpp main.cpp QtHttpForS.ui 客戶端代碼: QtHttpForC.h QtHttpForC.cpp mian.cpp QtHttpForC.ui 程序運(yùn)行效果: GET請求: POST請求: POST請求使用postman測試: 注意: 可以發(fā)現(xiàn),在使用postman進(jìn)行POST請求發(fā)送時,服務(wù)器接收到的請求頭與QTSocket的POST請求的請求頭

    2023年04月22日
    瀏覽(23)
  • 【Jmeter】信息頭管理器(HTTP Header Manager) - 發(fā)送Post請求數(shù)據(jù)為json格式

    【Jmeter】信息頭管理器(HTTP Header Manager) - 發(fā)送Post請求數(shù)據(jù)為json格式

    將 json 格式 請求數(shù)據(jù)輸入 HTTP 請求 中的 Body Data (消息體數(shù)據(jù) / 請求入?yún)? 右擊 Thread (線程組) 鼠標(biāo)移至 Add (添加) → Config Element (配置元件) 點(diǎn)擊 HTTP Header Manager (HTTP信息頭管理器) 即可完成信息頭管理器新建 進(jìn)入 HTTP Header Manager (HTTP信息頭管理器) 頁面 點(diǎn)擊下方 Add (添加) Nam

    2024年02月07日
    瀏覽(18)
  • c# 設(shè)置代理服務(wù)器發(fā)送http請求
  • java 發(fā)送 http 文件 post,form-data格式的數(shù)據(jù),MultipartEntityBuilder addTextBody中文亂碼

    java 發(fā)送 http 文件 post,form-data格式的數(shù)據(jù),MultipartEntityBuilder addTextBody中文亂碼

    平常我們對接第三方都是以json的數(shù)據(jù)進(jìn)行數(shù)據(jù)交互的,這次第三方接口只支持form-data格式的表單數(shù)據(jù),傳json數(shù)據(jù)對方不支持,通過百度和嘗試各種方案最終完美解決,后期再慢慢優(yōu)化吧。還有一個問題,數(shù)據(jù)中包含中文的戶,到第三方是亂碼的,經(jīng)過百度參考前輩的經(jīng)驗(yàn),

    2024年02月13日
    瀏覽(22)
  • MQTT協(xié)議-發(fā)布消息(服務(wù)器向客戶端發(fā)送)

    MQTT協(xié)議-發(fā)布消息(服務(wù)器向客戶端發(fā)送)

    發(fā)布消息報文組成:https://blog.csdn.net/weixin_46251230/article/details/129414158 在了解了發(fā)布信息的PUBLISH報文后,就可以分析出阿里云服務(wù)器向本地客戶端發(fā)送的報文數(shù)據(jù)了 實(shí)驗(yàn)前需要在阿里云創(chuàng)建產(chǎn)品和設(shè)備,并創(chuàng)建簡單的溫度和濕度物模型:https://blog.csdn.net/weixin_46251230/article/de

    2024年02月06日
    瀏覽(65)
  • 論如何本地搭建個人hMailServer郵件服務(wù)遠(yuǎn)程發(fā)送郵件無需域名公網(wǎng)服務(wù)器?

    論如何本地搭建個人hMailServer郵件服務(wù)遠(yuǎn)程發(fā)送郵件無需域名公網(wǎng)服務(wù)器?

    ???? 博主貓頭虎(????)帶您 Go to New World??? ?? 博客首頁 ——????貓頭虎的博客?? ?? 《面試題大全專欄》 ?? 文章圖文并茂??生動形象??簡單易學(xué)!歡迎大家來踩踩~?? ?? 《IDEA開發(fā)秘籍專欄》 ?? 學(xué)會IDEA常用操作,工作效率翻倍~?? ?? 《100天精通Golang(基礎(chǔ)

    2024年01月24日
    瀏覽(119)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包