This code works fine when deployed with 'chalice local' but when I deploy it with 'chalice deploy' and send a post request to the endpoint I am greeted with a status: 504 gateway timeout and message: "Endpoint request timed out".
from chalice import Chalice
from sqlalchemy import create_engine
app = Chalice(app_name='demo')
app.debug = True
engine = create_engine('postgresql://postgres:postgres@DATABASE_URI:5432/playground')
@app.route('/', methods=['POST'])
def index():
req_data = app.current_request.to_dict()
query_params = req_data['query_params']
name = str(query_params['name'])
age = int(query_params['age'])
with engine.connect() as conn:
conn.execute("INSERT INTO demo VALUES (%s, %s);", (name, age))
return {
'message': 'successfully inserted data with:',
'name': name,
'age': age
}