β β β Uππ»βΊπ«Δπ¬πβ β β β
π¦Bottle deployment method of web service and postman interface:
Bottle is a fast, concise, and lightweight WSIG-based micro web framework. This framework consists of only one .py file and does not depend on any other modules except the Python standard library.
from bottle import route, request, run<font></font>
import requests<font></font>
import cv2<font></font>
import numpy as np<font></font>
<font></font>
@route('/testimg',method='POST')#<font></font>
def testimg():<font></font>
try:<font></font>
params<font></font>
result = {}<font></font>
result["name"] = request.query.name#<font></font>
result["nums"] = request.query.nums<font></font>
<font></font>
#json<font></font>
#print(request.json)<font></font>
urllist = request.json["urllist"]<font></font>
#print(type(urllist))<font></font>
#print(urllist)<font></font>
imgPath = []<font></font>
for i in range(len(urllist)):<font></font>
imgPath.append(urllist[i])<font></font>
<font></font>
for i in range(len(imgPath)):<font></font>
#print(imgPath[i])<font></font>
#url<font></font>
rev = requests.get(imgPath[i], verify=False) # , timeout=config.timeout<font></font>
img = cv2.imdecode(np.frombuffer(rev.content, np.uint8), cv2.IMREAD_COLOR) # η<font></font>
rec = 0<font></font>
<font></font>
return str(rec)<font></font>
except BaseException as e:<font></font>
logger.exception(e)<font></font>
return str(0)<font></font>
<font></font>
if name == "main":<font></font>
<font></font>
run(host='172.17.0.2', port=49166, debug=False)
Postman interface test.
params passes parameters.
The body transmits text data such as json.
@Phenicia
β β β Uππ»βΊπ«Δπ¬πβ β β β
π¦Bottle deployment method of web service and postman interface:
Bottle is a fast, concise, and lightweight WSIG-based micro web framework. This framework consists of only one .py file and does not depend on any other modules except the Python standard library.
from bottle import route, request, run<font></font>
import requests<font></font>
import cv2<font></font>
import numpy as np<font></font>
<font></font>
@route('/testimg',method='POST')#<font></font>
def testimg():<font></font>
try:<font></font>
params<font></font>
result = {}<font></font>
result["name"] = request.query.name#<font></font>
result["nums"] = request.query.nums<font></font>
<font></font>
#json<font></font>
#print(request.json)<font></font>
urllist = request.json["urllist"]<font></font>
#print(type(urllist))<font></font>
#print(urllist)<font></font>
imgPath = []<font></font>
for i in range(len(urllist)):<font></font>
imgPath.append(urllist[i])<font></font>
<font></font>
for i in range(len(imgPath)):<font></font>
#print(imgPath[i])<font></font>
#url<font></font>
rev = requests.get(imgPath[i], verify=False) # , timeout=config.timeout<font></font>
img = cv2.imdecode(np.frombuffer(rev.content, np.uint8), cv2.IMREAD_COLOR) # η<font></font>
rec = 0<font></font>
<font></font>
return str(rec)<font></font>
except BaseException as e:<font></font>
logger.exception(e)<font></font>
return str(0)<font></font>
<font></font>
if name == "main":<font></font>
<font></font>
run(host='172.17.0.2', port=49166, debug=False)
Postman interface test.
params passes parameters.
The body transmits text data such as json.
@Phenicia
β β β Uππ»βΊπ«Δπ¬πβ β β β