You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
2.2 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<title>Sentiment Analysis Web App</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
"use strict";
function submitForm(oFormElement) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var result = parseFloat(xhr.responseText);
var resultElement = document.getElementById('result');
if (result == 0) {
resultElement.className = 'bg-danger';
resultElement.innerHTML = 'Your review was NEGATIVE!';
} else {
resultElement.className = 'bg-success';
resultElement.innerHTML = 'Your review was POSITIVE!';
}
}
xhr.open (oFormElement.method, oFormElement.action, true);
var review = document.getElementById('review');
xhr.send (review.value);
return false;
}
</script>
</head>
<body>
<div class="container">
<h1>Is your review positive, or negative?</h1>
<p>Enter your review below and click submit to find out...</p>
<form method="POST"
action="https://iypjgdv6y4.execute-api.us-east-2.amazonaws.com/prod/"
onsubmit="return submitForm(this);" > <!-- HERE IS WHERE YOU NEED TO ENTER THE API URL -->
<div class="form-group">
<label for="review">Review:</label>
<textarea class="form-control" rows="5" id="review">Please write your review here.</textarea>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<h1 class="bg-success" id="result"></h1>
</div>
</body>
</html>