Python 3.x 如何在Google云函数上部署基本python函数(带包)
我试图部署一个基本的python函数,该函数通过Google函数(浏览器编辑器)使用HTTP触发器调用api 以下是我尝试部署的功能:Python 3.x 如何在Google云函数上部署基本python函数(带包),python-3.x,http,google-cloud-platform,google-cloud-functions,Python 3.x,Http,Google Cloud Platform,Google Cloud Functions,我试图部署一个基本的python函数,该函数通过Google函数(浏览器编辑器)使用HTTP触发器调用api 以下是我尝试部署的功能: import requests import json def call_api(): API_URL = 'https://some-api.com/v1' API_TOKEN = 'some-api-token' result = requests.get(API_URL+"/contacts?access_token="+AP
import requests
import json
def call_api():
API_URL = 'https://some-api.com/v1'
API_TOKEN = 'some-api-token'
result = requests.get(API_URL+"/contacts?access_token="+API_TOKEN).json()
print(result)
call_api()
My requirements.txt包含:
requests==2.21.0
但是,每次尝试部署该函数时,都会发生以下错误:
Unknown resource type
我做错了什么?该功能在我的本地计算机上运行正常。有关更多信息,请参阅。这是我在查看代码时想到的:
- 缺少
参数(request
)def call\u api(request):
- 末尾缺少return(您不需要打印它,只需将它返回给调用者)
- 在文件末尾调用
将仅在本地调用该函数,CFs不需要这样做call\u api()
gcloud函数部署调用\u api——运行时Python 37——触发http进行部署