concept browser in category aws
appears as: browser, browser, browsers

This is an excerpt from Manning's book AI as a Service: Serverless machine learning with AWS.

This is an excerpt from Manning's book AWS Lambda in Action: Event-driven serverless applications.
Listing 7.3. greetings.js (JavaScript in the browser)
AWS.config.region = '<REGION>'; #1 AWS.config.credentials = new AWS.CognitoIdentityCredentials({ #2 IdentityPoolId: '<IDENTITY-POOL-ID>', #2 }); #2 var lambda = new AWS.Lambda(); #3 function returnGreetings() { document.getElementById('submitButton').disabled = true; var name = document.getElementById('name'); var input; if (name.value == null || name.value == '') { input = {}; } else { input = { name: name.value }; } lambda.invoke({ #4 FunctionName: 'greetingsOnDemand', #5 Payload: JSON.stringify(input) #6 }, function(err, data) { var result = document.getElementById('result'); if (err) { console.log(err, err.stack); result.innerHTML = err; #7 } else { var output = JSON.parse(data.Payload); #8 result.innerHTML = output; #9 } document.getElementById('submitButton').disabled = false; }); } var form = document.getElementById('greetingsForm'); form.addEventListener('submit', function(evt) { #10 evt.preventDefault(); #11 returnGreetings(); #12 });
This example uses both client-side (running in the browser) and server-side (running in Lambda functions) code. Because the code running in the browser is JavaScript, the Lambda function examples are also provided in JavaScript. The implementation of those functions in Python is left as an exercise for you to do on your own, because it doesn’t change the architecture or the logic of the application.