Код функции следующий
handler.py
импортировать JSON
Код: Выделить всё
def ask(event, context):
body = {
"message": f"Go Serverless v3.0! Your function executed successfully! Length ",
"input": event,
}
response = {"statusCode": 200, "body": json.dumps(body)}
return response
сервис: rag-se-aws-lambda
frameworkVersion: '3'
Код: Выделить всё
provider:
name: aws
runtime: python3.11
package:
individually: true
functions:
ask:
handler: handler.ask
events:
- httpApi:
path: /
method: post
Код: Выделить всё
import json
from src.my_function import my_function
def ask(event, context):
my_function()
body = {
"message": f"Go Serverless v3.0! Your function executed successfully! Length ",
"input": event,
}
response = {"statusCode": 200, "body": json.dumps(body)}
return response
Невозможно импортировать модуль «обработчик»: нет модуля с именем «my_function»
Кстати, если файл < Strong>my_function.py перемещается в ту же корневую папку, где определен handler.py, все работает.
Что мне делать, чтобы быть можно ли импортировать функцию из другой папки при использовании функций Python AWS Lambda?
Подробнее здесь: https://stackoverflow.com/questions/784 ... ferent-fil