HTML code
<html>
<head>
<style>
body {
background-color: yellow;
font-family:Lucida Sans Unicode;
}
.center {
text-align: center;
color: Brown;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: orange;
}
li {
float: left;
}
li a {
display: block;
color: brown;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover {
background-color: yellow;
}
</style>
</head>
<h1>
</h1>
<h1>Click on Bagel for today's Price Information</h1>
<br>
<br>
<form method="POST" action="https://j7qtefdvoh.execute-api.us-east-1.amazonaws.com/prod">
<label>Bagel:</label>
<select name="my-field">
<option value="plain">plain</option>
<option value="wheat">wheat</option>
</select>
<BR>
<input type="submit" value="Submit form">
<br>
<br>
<img src="images/bakery.jpg" alt="Plain Bagel" width="1200" height="400">
</form>
</html>
Lambda function to retrieve dynamodb data and display web page
const AWS = require('aws-sdk');
const querystring = require('querystring');
global.my_field;
global.docCleint;
let docClient = new AWS.DynamoDB.DocumentClient({region: 'us-east-1'});
// Set this to the region you upload the Lambda function to.
AWS.config.region = 'us-east-1';
exports.handler = function(evt, context, callback) {
// Our raw request body will be in evt.body.
const params = querystring.parse(evt.body);
// Our field from the request.
let my_field = params['my-field'];
var prec = {
TableName: 'Products',
Key: {
"bname": my_field
}
};
docClient.get(prec, function(err, data){
if (err){
callback(err, null);
}else{
// JSON.stringify(data, null, 2)
const html = `<!DOCTYPE html><html>
<head>
<style>
body {
background-color: yellow;
font-family:Lucida Sans Unicode;
}
.center {
text-align: center;
color: Brown;
}
</style>
</head>
<h1>
</h1>
<br>
<br>
<br>
<h1 class="center">Today's Bagel Price</h1>
<p>Price Per Dozen ` + data.Item.price + `</p>`;
callback(null, html);
}
});
};
Subscribe to:
Posts (Atom)
To All, If you are working in starter accounts please move the work into the classroom account so I can review. For the previous ...
-
To All, If you are working in starter accounts please move the work into the classroom account so I can review. For the previous ...
-
Classroom blog: awsuconn.blogspot.com ENGR-100 3/24/2019, 9:40 PM Final Web Site Project due last day of classes Fri., May 3 Funct...
-
Classroom blog: awsuconn.blogspot.com ENGR-100 2/20/2019, 10:16 PM Instructions for setting an amazon S3 bucket as a publicly accessi...
No comments:
Post a Comment