Bottle部署web服务及postman接口的方法
作者:Chapmancp 时间:2022-06-14 23:38:53
Bottle是一个快速、简洁、轻量级的基于WSIG的微型Web框架,此框架只由一个 .py 文件,除了Python的标准库外,其不依赖任何其他模块。
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)
postman接口测试。
params传递参数。
body传递json等文本数据。
来源:https://blog.csdn.net/Chapmancp/article/details/112601819
标签:Bottle,web,postman,接口
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python Django框架实现web端分页呈现数据
2022-07-03 03:47:14
Python 实现淘宝秒杀的示例代码
2021-02-19 14:25:39
Python实现子类调用父类的初始化实例
2023-09-20 00:25:27
![](https://img.aspxhome.com/file/2023/6/70136_0s.jpg)
Python中类的初始化特殊方法
2021-05-26 14:50:01
解决Python发送Http请求时,中文乱码的问题
2021-02-02 05:11:39
使用 Supervisor 监控 Python3 进程方式
2021-06-21 11:48:13
![](https://img.aspxhome.com/file/2023/2/90422_0s.jpg)
python导入导出redis数据的实现
2023-02-24 11:10:55
CSS实现完美垂直居中
2007-09-22 09:29:00
Python基于wordcloud及jieba实现中国地图词云图
2021-03-31 15:08:53
![](https://img.aspxhome.com/file/2023/8/117318_0s.jpg)
hmac模块生成加入了密钥的消息摘要详解
2023-05-17 09:26:46
![](https://img.aspxhome.com/file/2023/3/70893_0s.png)
python timestamp和datetime之间转换详解
2021-02-07 11:17:51
widows下安装pycurl并利用pycurl请求https地址的方法
2023-07-09 03:21:18
![](https://img.aspxhome.com/file/2023/4/61204_0s.jpg)
如何用ASP创建日志文件
2008-03-10 17:27:00
将pytorch转成longtensor的简单方法
2021-10-25 02:42:56
python异常处理try的实例小结
2022-01-25 06:06:51
python 根据时间来生成唯一的字符串方法
2022-12-25 14:49:48
教你如何利用Python批量翻译英文Word文档并保留格式
2022-10-18 21:27:17
![](https://img.aspxhome.com/file/2023/5/121035_0s.png)
在 Django/Flask 开发服务器上使用 HTTPS
2023-02-21 22:15:33
使用Python的Django和layim实现即时通讯的方法
2022-05-29 00:41:33
![](https://img.aspxhome.com/file/2023/0/77570_0s.jpg)
使用 TRUNCATE TABLE 删除所有行
2008-04-24 19:20:00