python - 无法在 Heroku 上的 python 应用程序中调用外部 API
问题描述
我已经在 heroku 上部署了一个带有烧瓶服务器的 python 应用程序,它调用了一个外部 API,但我没有得到任何响应。
它在本地机器上运行良好,但在 heroku 上的响应为空
我的python代码:
url = f'https://cdn-api.co-vin.in/api/v2/appointment/sessions/calendarByPin?pincode={pincode}&date={date}'
headersc = {
'authority': 'cdn-api.co-vin.in',
'accept': 'application/json, text/plain, */*',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.8.107.794 Safari/537.36',
'origin': 'https://www.cowin.gov.in',
'sec-fetch-site': 'cross-site',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
'referer': 'https://www.cowin.gov.in/home',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
'if-none-match': 'W/"7b1e-u5AO2iIdcDpbt4Qo1JbYPHtUqx8"',
}
reposne_data = requests.request(
"GET", url, headers=headersc, timeout=8
)
登录heruko
2021-05-10T01:19:01.889274+00:00 app[web.1]: Expecting value: line 1 column 1 (char 0)
解决方案
推荐阅读
- r - 无法在没有 OneDrive API 的情况下使用 Power BI 中的 R 脚本在受保护的 OneDrive 文件夹上写入 csv 文件
- c# - 检查对象访问链中的 null
- javascript - 如何逐个运行 mocha 测试模块?
- c - 将无符号字符数组返回到主函数
- google-apps-script - 如何摆脱表单插件菜单中的安装按钮?
- python - 为什么 .argmax 返回 1 而不是最大值?
- postgresql - Postgres聚合函数返回错误值,状态转换函数ok
- javascript - 查找内联脚本的容器
- c# - 如何在子类中处理 XmlWriter.Create
- admin - Magento2管理面板arning:file_put_contents():仅写入68字节中的0,可能是可用磁盘空间不足