Bottle是一個快速、簡潔、輕量級的基于WSIG的微型Web框架,此框架只由一個 .py 文件,除了Python的標(biāo)準(zhǔn)庫外,其不依賴任何其他模塊。
from bottle import route, request, run import requests import cv2 import numpy as np @route('/testimg',method='POST')# def testimg(): try: #獲取對應(yīng)params值 result = {} result["name"] = request.query.name# result["nums"] = request.query.nums #獲取json對應(yīng)內(nèi)容 #print(request.json) urllist = request.json["urllist"] #print(type(urllist)) #print(urllist) imgPath = [] for i in range(len(urllist)): imgPath.append(urllist[i]) for i in range(len(imgPath)): #print(imgPath[i]) #基于url獲取數(shù)據(jù) rev = requests.get(imgPath[i], verify=False) # , timeout=config.timeout img = cv2.imdecode(np.frombuffer(rev.content, np.uint8), cv2.IMREAD_COLOR) # 直接解碼網(wǎng)絡(luò)數(shù)據(jù),獲得bgr圖片 rec = 0 return str(rec) except BaseException as e: logger.exception(e) return str(0) if __name__ == "__main__": run(host='172.17.0.2', port=49166, debug=False)
postman接口測試。
params傳遞參數(shù)。
body傳遞json等文本數(shù)據(jù)。
到此這篇關(guān)于Bottle部署web服務(wù)及postman接口的方法的文章就介紹到這了,更多相關(guān)Bottle部署web服務(wù)postman接口內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標(biāo)簽:臺州 綿陽 鶴崗 株洲 哈密 鎮(zhèn)江 商丘 平頂山
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Bottle部署web服務(wù)及postman接口的方法》,本文關(guān)鍵詞 Bottle,部署,web,服務(wù),及,postman,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。