python - 当我已经在虚拟环境中使用 django 运行 API 端点时,如何部署 tabpy 代码?
问题描述
我正在尝试在 python 中使用 django 并在 R 中使用 restrserve 创建一个 api 端点,并在 tabpy 中部署以下代码以与 tableau 连接,我正面临这个错误。有人可以推荐任何解决方案。
错误信息:
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=9004): 最大重试次数超过 url: /endpoints (由 NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000016136C007C8>: 未能建立新连接: [ WinError 10061] 由于目标机器主动拒绝,无法建立连接'))
代码:
import tabpy_client
import requests
client = tabpy_client.Client('http://127.0.0.1:9004')
def external_services_say_hello(message, service):
if service == 'PYTHON':
r = requests.post('http://127.0.0.1:8000/', data ={'message': message})
elif service == 'R':
r = requests.post('http://localhost:8080/hello', data = {'message': message,})
serviceResult = r.json()
return serviceResult['result']
client.deploy('external_services_say_hello', external_services_say_hello, 'Make Python or R say Hello or anything you want.', override = True)
print('*** Model deployed successfully ***')
提前致谢!
解决方案
推荐阅读
- pandas - Pandas:技术上叫什么“字符串函数名”?
- graphics - 理解 glm::透视矩阵
- facebook - Facebook Messenger 链接共享不适用于消息
- unity3d - 在 Unity 中烘焙光照贴图时出现可怕的效果。阴影与模型不匹配
- python - 梯度下降中的 Inf 和 Nan
- android - Android Camera2 StateCallback onOpened 抛出随机错误
- browser - 将电报“tg”链接与浏览器扩展或 WEB-UI 关联
- c++ - 使用 std::format 将 time_point 转换为字符串,格式包括日期、时间和亚秒
- mongodb - 如何使用 multer 在 MongoDB 中上传多个图像?
- ethereum - 如何存储要在智能合约中使用的数据?