我正在尝试在Python Lambda中执行一个简单的多行Curl请求。
我的Lambda将包含非常少的代码,因此我想通过内联编辑代码来简化事情。因为我要内联编辑Lambda,所以不能使用任何包。相反,我正在尝试使用子过程。这是我到目前为止的内容:
def lambda_handler(event, context):
import subprocess
result = subprocess.call("curl -I http://foo.bar", shell=True)
return result
我要运行的curl请求是:
curl -H 'Content-Type: application/json' -d '{"data":"{\"message\":\"hello world\"}","name":"my-event","channel":"my-channel"}' \
"https://api.pusherapp.com/apps/12345/events?"\
"body_md5=12345&"\
"auth_version=1.0&"\
"auth_key=12345&"\
"auth_timestamp=12345&"\
"auth_signature=12345&"
关于如何将这两者融合在一起的任何想法都将大有帮助。谢谢!