broadfield-dev's picture
Update templates/index.html
9d0bb18 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Craigslist Search</title>
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<style>
/* Custom styles for hover effects and card shadows */
.card {
transition: transform time.sleep(0.2s), box-shadow 0.2s;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
/* Ensure cards are uniform height */
.card-content {
min-height: 120px;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen flex flex-col">
<!-- Header -->
<header class="bg-blue-600 text-white py-4 shadow-md">
<div class="container mx-auto px-4">
<h1 class="text-2xl font-bold">Craigslist Search</h1>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8 flex-grow">
<!-- Search Form -->
<form method="POST" class="bg-white p-6 rounded-lg shadow-md mb-8 max-w-2xl mx-auto">
<div class="flex flex-col md:flex-row gap-4">
<input
type="text"
name="query"
value="{{ query }}"
placeholder="Enter search query (e.g., car)"
class="flex-grow p-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
required
>
<select
name="city"
class="p-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
>
{% for city in cities %}
<option value="{{ city }}" {% if city == selected_city %}selected{% endif %}>
{{ city.capitalize() }}
</option>
{% endfor %}
</select>
<button
type="submit"
class="bg-blue-600 text-white px-6 py-3 rounded-lg hover:bg-blue-700 transition-colors"
>
Search
</button>
</div>
</form>
<!-- Error Message -->
{% if error %}
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-8 max-w-2xl mx-auto rounded">
{{ error }}
</div>
{% endif %}
<!-- Search Results -->
{% if posts %}
<h2 class="text-xl font-semibold mb-6">Search Results</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
{% for post in posts %}
<a
href="{{ post.link }}"
class="card bg-white rounded-lg shadow-md overflow-hidden no-underline text-gray-800"
>
<div class="card-content p-4">
<h3 class="text-lg font-semibold truncate">{{ post.title }}</h3>
<p class="text-gray-600 mt-1">Price: {{ post.price }}</p>
<p class="text-gray-600">Location: {{ post.location }}</p>
<p class="text-gray-500 text-sm mt-1">City: {{ post.city }}</p>
</div>
</a>
{% endfor %}
</div>
{% else %}
<p class="text-gray-600 text-center">No results found. Try a different query or city.</p>
{% endif %}
</main>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-4">
<div class="container mx-auto px-4 text-center">
<p>© {{ current_year }} Craigslist Search. All rights reserved.</p>
</div>
</footer>
</body>
</html>