Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Cook a Recipe: Create a Web application using AWS Amplify

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Cook a Recipe: Create a Web application using AWS Amplify


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Image description

Static Website

A static website, as in contrast to a typical dynamic website, renders the webpage at the time of request and instead delivers pre-built HTML, CSS, and JavaScript files to a web browser.

Now, We are going to cook a simple static website using HTML and JavaScript which call the reverseStringCall api endpoint and Fetch the response, get it displayed on our website

Ingredient

Lets Jump to the recipe

Create an HTML page that calls a Rest API endpoint built using API Gateway and displays the API Response

Create a java script file that calls the API endpoint from API Gateway, fetch the result and get it displayed to HTML file

JavaScript is an extremely popular scripting language that may be used on both the client and the server. Our websites require JavaScript because it makes them interactive.
Here, We are going to add a JavaScript script code that makes an API call, retrieves the response, and displays it to the HTML form

Copy the below code to a notepad and save it as main.js

  form.addEventListener('submit', function(e) {
    // Prevent default behavior:
    e.preventDefault();
    // Create new FormData object
    const formData = new FormData(form);
    const formDataObject = Object.fromEntries(formData.entries());
    // Post the payload using Fetch:
    fetch('<Invoke URL>', {
      method: 'POST',
      body: JSON.stringify(formDataObject)
    }).then(res => res.json()).then(data => {
//log the response obtained to the browser console
      console.log(data);
// call to the function displayToHTML
      displayToHTML(data)
    })

    function displayToHTML(data) {
      const form = document.getElementById('form');
      document.getElementById("demo").innerHTML = ' < span > Reversed String is: '+data.reversed_string + ' < /span>';
    }
  })

Invoke URL
When you deploy your API, you deploy to a stage, a base URL is generated which is also called as the invoke URL
Image description
All APIs created with API Gateway will follow the same pattern as the invoke URL above, with the ID of the API and the Region in which it was created, followed by a stage, and then the resource and resource path you want to expose.

fetch('<Invoke URL>', {
Here, we have to specify the Invoke URL obtained from API Gateway

Image description

Create a CSS stylesheet file to beautify and format the html file.

CSS allows you to customize the color, font, text size, spacing between elements, how elements are positioned and laid out, what background images or background colors are to be used, different displays for different devices and screen sizes, and much more!

Here, We are going to create an external style sheet, with which you can change the look of an entire website by changing just one file!

Copy the below code to the notepad and save it as main.css

body {
        background-color: #FFFFFF;
        }
    label, button {
        color: #000080;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 20px;
        margin-left: 40px;
        }
     input {
        color: #00BFFF;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 20px;
        margin-left: 20px;
        }

      p {
        color: #000080;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 20px;
        margin-left: 40px;
      }

Create an HTML page that calls a Rest API endpoint, Link the CSS and JS files to it

I am going to create a simple html page with a Text field which accepts the input string that needs to be reversed and a Submit button.

Open your favorite text editor on your computer.
Create a new file and paste the following HTML in it:

<!--- HTML form data --->
<html>
<head> 
<title> ReverseString Checker</title>
<!--- Linking the css file  --->
<link rel="stylesheet" href="main.css">

</head>

<body>
<form id='form'>
<label for="Input">Enter the String to be reversed</label>
    <input name="first_name" type="text">
    <button type="submit">Submit</button>
</form> 
<p id= "demo"></p>

<!--- linking the js file  --->
<script src="main.js"></script>

</body>

</html>

Yes, Our webpage is ready, Now lets get it deployed using AWS Amplify

Deploy a website using AWS Amplify

Now we are going to deploy the above html file as a webapplication using AWS Amplify

AWS Amplify

AWS Amplify is a set of products and tools that enable mobile and front-end web developers to build and deploy secure, scalable full-stack applications, powered by AWS.

Ingredient

  • The above html file saved as index.html

Prerequisites

  • Compress the files index.html, main.js and main.css and keep it ready

Image description
Image description

  • Log into AWS account with a valid user credentials (Root user not preferred)

Steps to create

  • Open the AWS Amplify service from aws console

Image description

  • Click Get Started button

Image description

  • Now Click Get Started button under Host your web app section , as we have already created the resources such as html, css and js files and we just need to deploy them

Image description

  • Now you will be navigated to *Get started with Amplify Hosting page *

  • Select without GIT Provider option, because we have saved the files local system and click Continue button
    Note, GIT is a source code management system and we are not using it for this cooking this recipe now

Image description

  • You will be navigated to Manual Deploy Page Specify the App name, Environment name

Drag and drop option will be selected by default for Method, Leave it as it is

Here we are going to drag and drop our zipped file

Image description

  • Click Choose File and Select the Zipped folder

  • Make sure the folder name is correct, Click Save and Deploy

Image description

  • A deployment process will automatically begin

Image description

  • Now wait for a couple of minutes and You will see a green bar, which indicates your deployment is completed
  • You can also see the application url link below Domain

Image description

Launch the Application

  • Click on the application url link and launch the web application

  • Yaay, Our application is ready

Image description

  • Now Give some input string and click Submit button, See Reversed version of your string is displayed on the Website

Image description

View the Network Tab browser console and ensure if the api endpoint called and response is generated

Right click on the webpage and click on Inspect option to launch the browser console and network tabs

Image description

  • Click Network and get into the Network tab
  • Click Submit button and observe the Network tab, You can see the api endpoint getting called once you click the submit button and JSON Response is getting generated

Image description

Click the Payload and observe the data sent as the input to the lambda function which is being triggered using API

Image description

  • Click the Console and come to Console Tab You can see that the Response is getting displayed on console as per our JavaScript code

Code snippet from main.js below

//log the response obtained to the browser console
console.log(data);

Image description

...



๐Ÿ“Œ Cook a Recipe: Create a Web application using AWS Amplify


๐Ÿ“ˆ 78.57 Punkte

๐Ÿ“Œ Cook a recipe with AWS: Create Canaries using Selenium Python test scripts


๐Ÿ“ˆ 49.37 Punkte

๐Ÿ“Œ Cook a recipe with AWS: Create Canaries using Selenium Python test scripts


๐Ÿ“ˆ 49.37 Punkte

๐Ÿ“Œ Cook a recipe with AWS: A simple API using API-Gateway


๐Ÿ“ˆ 41.94 Punkte

๐Ÿ“Œ Deploy Your First Web App on AWS with AWS Amplify, Lambda, DynamoDB and API Gateway


๐Ÿ“ˆ 38.29 Punkte

๐Ÿ“Œ The Amplify Series, Part 5: Uploading and retrieving images with Amplify Storage


๐Ÿ“ˆ 38.28 Punkte

๐Ÿ“Œ Cook a recipe with AWS: Dynamo DB Table


๐Ÿ“ˆ 36.84 Punkte

๐Ÿ“Œ Cook a recipe with AWS: Simple and Easy Lambda Functions


๐Ÿ“ˆ 36.84 Punkte

๐Ÿ“Œ Securing your NextJS Web Application with AWS Amplify and Cognito


๐Ÿ“ˆ 36.81 Punkte

๐Ÿ“Œ Medium CVE-2022-31518: Python-recipe-database project Python-recipe-database


๐Ÿ“ˆ 36.41 Punkte

๐Ÿ“Œ Paprika Recipe Manager 3.7.2 - Simple recipe management for everyone.


๐Ÿ“ˆ 36.41 Punkte

๐Ÿ“Œ CVE-2024-0384 | WP Recipe Maker Plugin up to 9.1.0 on WordPress Recipe Note cross site scripting


๐Ÿ“ˆ 36.41 Punkte

๐Ÿ“Œ Building Robust GraphQL APIs with AWS Amplify and AWS AppSync


๐Ÿ“ˆ 34.37 Punkte

๐Ÿ“Œ Building and Launching a Serverless GraphQL React Application with AWS Amplify: A Step-by-Step Guide


๐Ÿ“ˆ 32.9 Punkte

๐Ÿ“Œ The Battle of the AWS Managed Services: Amplify <-> Application Composer <-> Cloud Formation


๐Ÿ“ˆ 32.9 Punkte

๐Ÿ“Œ Connecting to AWS AppSync using Amplify for Flutter for our Football Match Center


๐Ÿ“ˆ 31.86 Punkte

๐Ÿ“Œ Why I build Virtual PhotoBooth using AWS Amplify ?


๐Ÿ“ˆ 31.86 Punkte

๐Ÿ“Œ Launching a Static Website using AWS Amplify with CI/CD! v1


๐Ÿ“ˆ 31.86 Punkte

๐Ÿ“Œ Full Stack Project Tutorial โ€“ Create a Recipe App Using React, Node.js and PostgreSQL


๐Ÿ“ˆ 30.74 Punkte

๐Ÿ“Œ Cook Up a Storm: Build a Recipe Finder App with React ๐Ÿฑ


๐Ÿ“ˆ 29.22 Punkte

๐Ÿ“Œ How to create a static website locally, push it to github, then to AWS S3 using AWS codepipeline and publish it automatically.


๐Ÿ“ˆ 27.76 Punkte

๐Ÿ“Œ Spring Boot 3 application on AWS Lambda - Part 3 Develop application with AWS Serverless Java Container


๐Ÿ“ˆ 27.51 Punkte

๐Ÿ“Œ AWS Amplify, another cool dude for developers to act?


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ Cross-Plattform: Der Support fรผr Flutter in AWS Amplify ist produktionsreif


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ How to Deploy a Next.js 13 Site with AWS Amplify


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ CI/CD pipelines with AWS Amplify


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ Amazon Location Service and AWS Amplify to Use Various Map Library


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ AWS Amplify: Let's add some unit tests into our pipeline


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ Build a Todo App with Next.js and AWS Amplify


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ Step by step: Build your first AWS Amplify and React App


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ Deploy Your Next.js App with AWS Amplify Like a Pro โ€” Itโ€™s Easier Than You Think


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ How to Build a Job Board With AWS Amplify and Nextjs


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ AWS Amplify and ChatGPT: one way to generate html mock files for our demos ๐Ÿค–


๐Ÿ“ˆ 26.76 Punkte

๐Ÿ“Œ AWS Amplify Through An Infrastructure Lens


๐Ÿ“ˆ 26.76 Punkte











matomo