当启动一个通过HTTP唤起的API服务时,需要用到接口测试,requests是其中最简单的方式之一
import requests
r = requests.get(url='http://localhost:8080/2021.07.22/GCT20210722')
if r.status_code != 200:# 状态码200表示连接成功,有正常返回值
print("pdfReportGenerator connection error")
else:
print("pdfReport is {}".format(r.text))# 获取返回值的内容