concept browser in category aws

appears as: browser, browser, browsers
AI as a Service: Serverless machine learning with AWS

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

Our webpack configuration will build all dependencies from src/index.js into the dist folder for us. This includes all of our source code and related modules, including JQuery. We can then simply deploy the dist directory to S3 to have a functional application.

Let’s test out our bot! Click the Build button on the top right and wait for the build to complete. Then select the Test Chatbot link to bring up a message panel on the right side, and try creating some to-dos. Figure 5.7 shows a sample session.

AWS Lambda in Action: Event-driven serverless applications

This is an excerpt from Manning's book AWS Lambda in Action: Event-driven serverless applications.

Figure 1.8. Using a JavaScript application running in the browser, back end architecture is simplified by serving only APIs to all clients.
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.