Skip to content

Commit

Permalink
Review page modify
Browse files Browse the repository at this point in the history
  • Loading branch information
charakamihiranga committed Sep 18, 2024
1 parent 8d97975 commit 289dcd2
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 26 deletions.
Binary file modified Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions Python-TextBlob with Flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def analyzereview():
sentiment = blob.sentiment.polarity

if sentiment > 0:
result = "Positive Review✅🎉"
result = "Positive Review✅"
elif sentiment < 0:
result = "Negative Review🫤"
result = "Negative Review☹️"
elif sentiment == 0:
result = "Neutral Review👍"
result = "Neutral Review😐"

return jsonify({'sentiment': result})

Expand Down
17 changes: 12 additions & 5 deletions Python-TextBlob with Flask/static/js/script.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
document.getElementById('review-form').addEventListener('submit', async function(event) {
event.preventDefault();
document.getElementById('review-form').addEventListener('submit', async function(event) {
event.preventDefault();

const reviewText = document.getElementById('review').value;
const reviewText = document.getElementById('review').value;

const response = await fetch('/analyzereview', {
try {
const response = await fetch('/analyzereview', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand All @@ -13,4 +14,10 @@

const data = await response.json();
document.getElementById('result').textContent = 'Sentiment: ' + data.sentiment;
});

// document.getElementById('review').value = '';
} catch (error) {
console.error('Error:', error);
document.getElementById('result').textContent = 'An error occurred. Please try again.';
}
});
74 changes: 56 additions & 18 deletions Python-TextBlob with Flask/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,92 @@
<title>Review Sentiment Analysis</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
font-family: 'Poppins', sans-serif;
background-color: #f0f2f5;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
min-height: 100vh;
margin: 0;
padding: 0;
}

.review-form {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
background-color: #ffffff;
padding: 2rem;
border-radius: 16px;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
max-width: 100%;
width: 400px;
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 1rem;
}

.review-form h2 {
font-size: 1.75rem;
margin: 0;
color: #333;
text-align: center;
}

.review-form textarea {
width: 100%;
padding: 10px;
padding: 1rem;
border: 1px solid #ddd;
border-radius: 5px;
border-radius: 8px;
resize: vertical;
margin-bottom: 15px;
font-size: 1rem;
box-sizing: border-box;
transition: border-color 0.3s;
}

.review-form textarea:focus {
border-color: #007bff;
outline: none;
}

.review-form button {
width: 100%;
padding: 10px;
background-color: #28a745;
padding: 0.75rem;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
font-size: 1.125rem;
transition: background-color 0.3s, transform 0.2s;
}

.review-form button:hover {
background-color: #218838;
background-color: #0056b3;
}

.review-form button:active {
transform: scale(0.98);
}

.result {
text-align: center;
font-size: 18px;
margin-top: 15px;
font-size: 1.125rem;
margin-top: 1rem;
color: #555;
}

@media (max-width: 480px) {
.review-form {
width: 90%;
padding: 1.5rem;
}

.review-form h2 {
font-size: 1.5rem;
}

.review-form button {
font-size: 1rem;
}
}
</style>
</head>
Expand All @@ -62,7 +100,7 @@
<div class="review-form">
<h2>Review Sentiment Analysis</h2>
<form id="review-form">
<textarea name="review" id="review" rows="5" placeholder="" required></textarea><br>
<textarea name="review" id="review" rows="5" placeholder="Enter your review here..." required></textarea>
<button type="submit">Submit Review</button>
</form>
<div class="result" id="result">
Expand Down

0 comments on commit 289dcd2

Please sign in to comment.