首页 > 解决方案 > 从 AWS lambda 在本地机器上执行代码

问题描述

对于一个大学项目,我创建了一个聊天机器人,它调用用 Python 编写的 lambda 函数。

import webbrowser
import boto3
import logging
from urllib.request import Request, urlopen
import json
def handler(event,callback):

function_type = event['currentIntent']['slots']['slotOne']
print('This went to the search')
webbrowser.open('www.google.com')
response = {
    "dialogAction": {
        "type": "Close",
        "fulfillmentState": "Fulfilled",
        "message": {
          "contentType": "SSML",
          "content": "opening google now"
                },
            }
        }
    return response

我可以在这个 lambda 中发送和接收信息,但我无法使用webbrowser导入打开 www.google.com。这在本地工作,我想知道是否有办法让我的 lambda 触发器代码本地保存在我的机器上,或者让我的 lambda 代码在我的聊天机器人调用时在本地执行。

标签: pythonamazon-web-servicesaws-lambda

解决方案


推荐阅读