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)
到此這篇關(guān)于Bottle部署web服務(wù)及postman接口的方法的文章就介紹到這了,更多相關(guān)Bottle部署web服務(wù)postman接口內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!