File size: 3,934 Bytes
1af2a0a
c0f9b4b
1af2a0a
c0f9b4b
 
1af2a0a
c0f9b4b
 
 
 
 
9d0bb18
c0f9b4b
 
 
 
 
 
 
 
 
 
1af2a0a
c0f9b4b
 
 
 
 
 
 
7e60a44
c0f9b4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e60a44
c0f9b4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d0bb18
c0f9b4b
 
1af2a0a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!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>