Today I tested the FASTAPI(python) lib with AWS Lambda URL . It worked as expected. Folowing is the code I used for it.
main.py
from fastapi import FastAPI
from mangum import Mangum
app = FastAPI()
handler = Mangum(app)
@app.get("/")
def baseurl():
return {"Hello from Base PATH"}
@app.get("/hello")
def baseurl():
return {"Hello from /hello PATH"}
@app.get('/user/{name}')
def show(name: str):
return {f"Hello from the /user PATH {name}"}
In the code you can see that the handler is wrapped around the Magnum (Line#9)to worked well with AWS lambda. After deploying I tested the functioanlity using Lambda URL which worked as expected hence we dont need the API gateway config anymore.
Testing Results:
Test#2 PATH= /hello
Test #3 PATH= /user/
Even the swagger URL also opened correctly: