from bottle import route, request, run
import requests
import cv2
import numpy as np
@route('/testimg',method='POST')#
def testimg():
try:
#获取对应params值
result = {}
result["name"] = request.query.name#
result["nums"] = request.query.nums
#获取json对应内容
#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获取数据
rev = requests.get(imgPath[i], verify=False) # , timeout=config.timeout
img = cv2.imdecode(np.frombuffer(rev.content, np.uint8), cv2.IMREAD_COLOR) # 直接解码网络数据,获得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)
到此这篇关于Bottle部署web服务及postman接口的方法的文章就介绍到这了,更多相关Bottle部署web服务postman接口内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!