Bottle部署web服務(wù)及postman接口的方法
更新時間:2021年01月15日 10:53:50 作者:Chapmancp
這篇文章主要介紹了Bottle部署web服務(wù)及postman接口的方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
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)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用postman進(jìn)行接口測試的方法(測試用戶管理模塊)
這篇文章主要介紹了使用postman進(jìn)行接口測試的方法(測試用戶管理模塊),本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2021-01-01PHP、JAVA、.NET這三種技術(shù)的區(qū)別分析
這篇文章主要介紹了PHP、JAVA、.NET這三種技術(shù)的區(qū)別分析,本文從多個方面介紹、對比了PHP、JAVA、.NET這三種技術(shù),需要的朋友可以參考下2014-08-08