jordaneremieff / mangum

AWS Lambda support for ASGI applications
https://mangum.io/
MIT License
1.67k stars 119 forks source link

AWS lambda function not identify the handler in FastAPI project #289

Closed parth-patel97 closed 1 year ago

parth-patel97 commented 1 year ago

When I try to upload the FastAPI on the lambda function I get this error. Would anyone be able to help me with this?

My Porject structure : README.md main.py requirements.txt routes/api.py src/dependencies/config.py src/endpoints/textGenerator.py

My main.py :-

from fastapi import FastAPI,Depends
from routes.api import router as api_router
from mangum import Mangum

app = FastAPI()
app.include_router(api_router)

handler = Mangum(app=app)

{ "errorMessage": "The adapter was unable to infer a handler to use for the event. This is likely related to how the Lambda function was invoked. (Are you testing locally? Make sure the request payload is valid for a supported handler.)", "errorType": "RuntimeError", "stackTrace": [ " File \"/opt/python/mangum/adapter.py\", line 76, in call\n handler = self.infer(event, context)\n", " File \"/opt/python/mangum/adapter.py\", line 68, in infer\n raise RuntimeError( # pragma: no cover\n" ] }