From 289dcd2531a7b9cd986668f0384ef000a061095d Mon Sep 17 00:00:00 2001 From: Charaka V Mihiranga <143955766+CharakaMihiranga@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:40:48 +0530 Subject: [PATCH] Review page modify --- .../__pycache__/app.cpython-312.pyc | Bin 1345 -> 1343 bytes Python-TextBlob with Flask/app.py | 6 +- .../static/js/script.js | 17 ++-- .../templates/index.html | 74 +++++++++++++----- 4 files changed, 71 insertions(+), 26 deletions(-) diff --git a/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc b/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc index dbf6ccfc91a5bf2142b846f4db3298910d1fe739..378adb2eedc24403904f46fcfd3bd42f469b0b36 100644 GIT binary patch delta 117 zcmX@ewV#XkG%qg~0}!<2y-M4#k@pXiyAY5UkYAixl3A9j5R_V$nOgp6PHU+sP}nau zJrP-W#?JRU`b$9?{8CFxiV}06>Oah%F=28L^D$o4PPQAILK6bJWN!#+Y*uBFVFUnb C;wjev delta 119 zcmdnbb&!kqG%qg~0}zO(y-M4(k@pXirx=hIkYAixl3A9j5R_V$nOgp6PV0yHeVwJk zKqLn8=OKD0=r~y2&!#XW|3h8 E0Kd8_cK`qY 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

-
+