codeby-hp's picture
adding files
28a0fff verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sentiment Analysis</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
animation: fadeIn 0.5s ease-out forwards;
}
body {
font-family: 'Inter', sans-serif;
}
.glass-card {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-gradient {
background-image: linear-gradient(to right, #4f46e5, #c026d3);
}
</style>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body class="bg-gray-900 text-white">
<div class="min-h-screen flex flex-col items-center justify-center p-4">
<div class="w-full max-w-2xl">
<div class="text-center mb-8 fade-in">
<h1 class="text-4xl md:text-5xl font-bold tracking-tight">Sentiment Analyzer</h1>
<p class="text-gray-400 mt-3 text-lg">Instantly analyze the sentiment of your text.</p>
</div>
<div class="glass-card rounded-2xl shadow-2xl p-8 fade-in" style="animation-delay: 0.2s;">
<form action="/predict" method="POST">
<div class="mb-6">
<label for="text" class="sr-only">Your text</label>
<textarea
id="text"
name="text"
rows="6"
required
class="w-full bg-gray-800 border-2 border-gray-700 rounded-lg px-4 py-3 text-base text-white placeholder-gray-500 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-all duration-300 resize-none"
placeholder="Enter text to analyze..."
></textarea>
</div>
<button
type="submit"
class="w-full btn-gradient text-white font-semibold py-3 rounded-lg transition-transform transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-purple-500 focus:ring-opacity-50"
>
Analyze Sentiment
</button>
</form>
{% if result is not none %}
<button
onclick="window.location.href='/'"
class="w-full mt-4 bg-gray-700 hover:bg-gray-600 text-white font-semibold py-3 rounded-lg transition-all duration-300"
>
New Analysis
</button>
{% endif %}
{% if result is not none %}
<div class="mt-8 pt-6 border-t border-gray-700 fade-in" style="animation-delay: 0.4s;">
{% if result == 1 %}
<div class="flex items-start space-x-4 bg-green-500/10 border border-green-500/30 text-green-300 px-5 py-4 rounded-lg">
<svg class="w-6 h-6 flex-shrink-0 mt-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<div class="flex-1">
<h4 class="text-lg font-semibold">Positive Sentiment</h4>
<p class="text-sm text-green-300/80">The analysis indicates a positive tone.</p>
{% if confidence %}
<div class="mt-2">
<span class="text-xs font-medium text-green-400">Confidence: {{ "%.2f"|format(confidence) }}%</span>
<div class="w-full bg-gray-700 rounded-full h-2 mt-1">
<div class="bg-green-500 h-2 rounded-full" style="width: {{ confidence }}%"></div>
</div>
</div>
{% endif %}
</div>
</div>
{% else %}
<div class="flex items-start space-x-4 bg-red-500/10 border border-red-500/30 text-red-300 px-5 py-4 rounded-lg">
<svg class="w-6 h-6 flex-shrink-0 mt-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<div class="flex-1">
<h4 class="text-lg font-semibold">Negative Sentiment</h4>
<p class="text-sm text-red-300/80">The analysis indicates a negative tone.</p>
{% if confidence %}
<div class="mt-2">
<span class="text-xs font-medium text-red-400">Confidence: {{ "%.2f"|format(confidence) }}%</span>
<div class="w-full bg-gray-700 rounded-full h-2 mt-1">
<div class="bg-red-500 h-2 rounded-full" style="width: {{ confidence }}%"></div>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
</div>
{% endif %}
</div>
</div>
</div>
</body>
</html>