diff --git a/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc b/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc index dbf6ccf..378adb2 100644 Binary files a/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc and b/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc differ diff --git a/Python-TextBlob with Flask/app.py b/Python-TextBlob with Flask/app.py index 3942b89..7a79bab 100644 --- a/Python-TextBlob with Flask/app.py +++ b/Python-TextBlob with Flask/app.py @@ -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}) diff --git a/Python-TextBlob with Flask/static/js/script.js b/Python-TextBlob with Flask/static/js/script.js index 1b22ff4..0c65b40 100644 --- a/Python-TextBlob with Flask/static/js/script.js +++ b/Python-TextBlob with Flask/static/js/script.js @@ -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' @@ -13,4 +14,10 @@ const data = await response.json(); document.getElementById('result').textContent = 'Sentiment: ' + data.sentiment; - }); \ No newline at end of file + + // document.getElementById('review').value = ''; + } catch (error) { + console.error('Error:', error); + document.getElementById('result').textContent = 'An error occurred. Please try again.'; + } +}); diff --git a/Python-TextBlob with Flask/templates/index.html b/Python-TextBlob with Flask/templates/index.html index 2f48b5e..bf11487 100644 --- a/Python-TextBlob with Flask/templates/index.html +++ b/Python-TextBlob with Flask/templates/index.html @@ -6,54 +6,92 @@ Review Sentiment Analysis @@ -62,7 +100,7 @@

Review Sentiment Analysis

-
+