Upload 4 files
Browse files- instance/jobs.db +0 -0
- templates/jobs.html +216 -0
- templates/prepme.html +90 -0
- templates/prepmeBkp.html +89 -0
instance/jobs.db
ADDED
|
Binary file (61.4 kB). View file
|
|
|
templates/jobs.html
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Job Applications</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css">
|
| 8 |
+
<style>
|
| 9 |
+
/* Semi-circle edges for search bar */
|
| 10 |
+
.search-input {
|
| 11 |
+
border-top-left-radius: 50px;
|
| 12 |
+
border-bottom-left-radius: 50px;
|
| 13 |
+
border-right: none;
|
| 14 |
+
}
|
| 15 |
+
.search-btn {
|
| 16 |
+
border-top-right-radius: 50px;
|
| 17 |
+
border-bottom-right-radius: 50px;
|
| 18 |
+
border-left: none;
|
| 19 |
+
}
|
| 20 |
+
/* Smaller pill for Download button */
|
| 21 |
+
.download-btn {
|
| 22 |
+
border-top-right-radius: 25px;
|
| 23 |
+
border-bottom-right-radius: 25px;
|
| 24 |
+
border-top-left-radius: 25px;
|
| 25 |
+
border-bottom-left-radius: 25px;
|
| 26 |
+
border-left: none;
|
| 27 |
+
margin-left: 2px;
|
| 28 |
+
padding: 0.375rem 0.75rem;
|
| 29 |
+
}
|
| 30 |
+
</style>
|
| 31 |
+
</head>
|
| 32 |
+
<body>
|
| 33 |
+
<div class="container mt-5">
|
| 34 |
+
<h1 class="text-center">Career Crafter</h1>
|
| 35 |
+
|
| 36 |
+
<!-- Tabs Navigation -->
|
| 37 |
+
<ul class="nav nav-tabs" id="jobTabs" role="tablist">
|
| 38 |
+
<li class="nav-item" role="presentation">
|
| 39 |
+
<button class="nav-link{% if not edit_job %} active{% endif %}" id="list-tab" data-bs-toggle="tab" data-bs-target="#list" type="button" role="tab" aria-controls="list" aria-selected="{{ 'true' if not edit_job else 'false' }}">Job List</button>
|
| 40 |
+
</li>
|
| 41 |
+
<li class="nav-item" role="presentation">
|
| 42 |
+
<button class="nav-link{% if edit_job %} active{% endif %}" id="add-tab" data-bs-toggle="tab" data-bs-target="#add" type="button" role="tab" aria-controls="add" aria-selected="{{ 'true' if edit_job else 'false' }}">Add Job</button>
|
| 43 |
+
</li>
|
| 44 |
+
<li class="nav-item" role="presentation">
|
| 45 |
+
<button class="nav-link" id="prepme-tab" data-bs-toggle="tab" data-bs-target="#prepme" type="button" role="tab" aria-controls="prepme" aria-selected="false">PrepMe</button>
|
| 46 |
+
</li>
|
| 47 |
+
</ul>
|
| 48 |
+
|
| 49 |
+
<!-- Tabs Content -->
|
| 50 |
+
<div class="tab-content" id="jobTabsContent">
|
| 51 |
+
<!-- Job List Tab -->
|
| 52 |
+
<div class="tab-pane fade{% if not edit_job %} show active{% endif %}" id="list" role="tabpanel" aria-labelledby="list-tab">
|
| 53 |
+
<!-- Status Counts -->
|
| 54 |
+
<div class="mb-3">
|
| 55 |
+
{# Clickable status filters #}
|
| 56 |
+
<a href="{{ url_for('jobs', search=search_query, sort=sort_by, direction=direction, status_filter='Applied') }}" class="badge bg-primary me-2 {% if status_filter=='Applied' %}bg-opacity-75{% endif %}">Applied: {{ applied_count }}</a>
|
| 57 |
+
<a href="{{ url_for('jobs', search=search_query, sort=sort_by, direction=direction, status_filter='Rejected') }}" class="badge bg-danger me-2 {% if status_filter=='Rejected' %}bg-opacity-75{% endif %}">Rejected: {{ rejected_count }}</a>
|
| 58 |
+
<a href="{{ url_for('jobs', search=search_query, sort=sort_by, direction=direction, status_filter='Interviewing') }}" class="badge bg-warning text-dark me-2 {% if status_filter=='Interviewing' %}bg-opacity-75{% endif %}">Interviewing: {{ interviewing_count }}</a>
|
| 59 |
+
<a href="{{ url_for('jobs', search=search_query) }}" class="badge bg-secondary">All</a>
|
| 60 |
+
</div>
|
| 61 |
+
<!-- Search Form centered like Google -->
|
| 62 |
+
<div class="row justify-content-center mb-4">
|
| 63 |
+
<div class="col-md-6">
|
| 64 |
+
<form method="get" action="{{ url_for('jobs') }}">
|
| 65 |
+
<div class="input-group">
|
| 66 |
+
<input type="search" class="form-control search-input" name="search" placeholder="Search by company, position, or status" value="{{ search_query }}">
|
| 67 |
+
<button class="btn btn-primary search-btn" type="submit">Search</button>
|
| 68 |
+
<a href="{{ url_for('download_jobs', search=search_query) }}" class="btn btn-success download-btn" type="button">CSV</a>
|
| 69 |
+
</div>
|
| 70 |
+
</form>
|
| 71 |
+
</div>
|
| 72 |
+
</div>
|
| 73 |
+
<h2 class="mt-2">Job List</h2>
|
| 74 |
+
<table class="table table-bordered">
|
| 75 |
+
<thead>
|
| 76 |
+
<tr>
|
| 77 |
+
<th>Company</th>
|
| 78 |
+
<th>
|
| 79 |
+
{% set pos_dir = 'desc' if sort_by=='position' and direction=='asc' else 'asc' %}
|
| 80 |
+
<a href="{{ url_for('jobs', search=search_query, sort='position', direction=pos_dir) }}">
|
| 81 |
+
Position
|
| 82 |
+
{% if sort_by=='position' %}
|
| 83 |
+
{% if direction=='asc' %} ▲ {% else %} ▼ {% endif %}
|
| 84 |
+
{% endif %}
|
| 85 |
+
</a>
|
| 86 |
+
</th>
|
| 87 |
+
<th>
|
| 88 |
+
{% set date_dir = 'desc' if sort_by=='date_applied' and direction=='asc' else 'asc' %}
|
| 89 |
+
<a href="{{ url_for('jobs', search=search_query, sort='date_applied', direction=date_dir) }}">
|
| 90 |
+
Date Applied
|
| 91 |
+
{% if sort_by=='date_applied' %}
|
| 92 |
+
{% if direction=='asc' %} ▲ {% else %} ▼ {% endif %}
|
| 93 |
+
{% endif %}
|
| 94 |
+
</a>
|
| 95 |
+
</th>
|
| 96 |
+
<th>
|
| 97 |
+
{% set status_dir = 'desc' if sort_by=='status' and direction=='asc' else 'asc' %}
|
| 98 |
+
<a href="{{ url_for('jobs', search=search_query, sort='status', direction=status_dir) }}">
|
| 99 |
+
Status
|
| 100 |
+
{% if sort_by=='status' %}
|
| 101 |
+
{% if direction=='asc' %} ▲ {% else %} ▼ {% endif %}
|
| 102 |
+
{% endif %}
|
| 103 |
+
</a>
|
| 104 |
+
</th>
|
| 105 |
+
<th>Resume Used</th>
|
| 106 |
+
<th>Interview Details</th>
|
| 107 |
+
<th>Comments</th>
|
| 108 |
+
<th>Link</th>
|
| 109 |
+
<th>Job Description</th>
|
| 110 |
+
<th>Actions</th>
|
| 111 |
+
</tr>
|
| 112 |
+
</thead>
|
| 113 |
+
<tbody>
|
| 114 |
+
{% for job in jobs %}
|
| 115 |
+
<tr>
|
| 116 |
+
<td>{{ job.company }}</td>
|
| 117 |
+
<td>{{ job.position }}</td>
|
| 118 |
+
<td>{{ job.date_applied }}</td>
|
| 119 |
+
<td>{{ job.status }}</td>
|
| 120 |
+
<td>{{ job.resume_used }}</td>
|
| 121 |
+
<td>{{ job.interview_details }}</td>
|
| 122 |
+
<td>{{ job.comments }}</td>
|
| 123 |
+
<td><a href="{{ job.link }}" target="_blank">Link</a></td>
|
| 124 |
+
<td>{{ job.job_description }}</td>
|
| 125 |
+
<td>
|
| 126 |
+
<form method="POST" action="/delete_job/{{ job.id }}" style="display:inline;">
|
| 127 |
+
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
|
| 128 |
+
</form>
|
| 129 |
+
<a href="/edit_job/{{ job.id }}" class="btn btn-sm btn-warning">Edit</a>
|
| 130 |
+
<button class="btn btn-sm btn-info prepme-btn" data-job-id="{{ job.id }}">PrepMe</button>
|
| 131 |
+
</td>
|
| 132 |
+
</tr>
|
| 133 |
+
{% endfor %}
|
| 134 |
+
</tbody>
|
| 135 |
+
</table>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<!-- Add Job Tab -->
|
| 139 |
+
<div class="tab-pane fade{% if edit_job %} show active{% endif %}" id="add" role="tabpanel" aria-labelledby="add-tab">
|
| 140 |
+
<form method="POST" action="{% if edit_job %}/edit_job/{{ edit_job.id }}{% else %}/jobs{% endif %}" class="mt-4">
|
| 141 |
+
<div class="mb-3">
|
| 142 |
+
<label for="company" class="form-label">Company</label>
|
| 143 |
+
<input type="text" class="form-control" id="company" name="company" value="{{ edit_job.company if edit_job else '' }}" required>
|
| 144 |
+
</div>
|
| 145 |
+
<div class="mb-3">
|
| 146 |
+
<label for="position" class="form-label">Position</label>
|
| 147 |
+
<input type="text" class="form-control" id="position" name="position" value="{{ edit_job.position if edit_job else '' }}" required>
|
| 148 |
+
</div>
|
| 149 |
+
<div class="mb-3">
|
| 150 |
+
<label for="resume_used" class="form-label">Resume Used</label>
|
| 151 |
+
<input type="text" class="form-control" id="resume_used" name="resume_used" value="{{ edit_job.resume_used if edit_job else '' }}">
|
| 152 |
+
</div>
|
| 153 |
+
<div class="mb-3">
|
| 154 |
+
<label for="date_applied" class="form-label">Date Applied</label>
|
| 155 |
+
<input type="date" class="form-control" id="date_applied" name="date_applied" value="{{ edit_job.date_applied if edit_job else '' }}">
|
| 156 |
+
</div>
|
| 157 |
+
<div class="mb-3">
|
| 158 |
+
<label for="status" class="form-label">Status</label>
|
| 159 |
+
<select class="form-control" id="status" name="status">
|
| 160 |
+
<option value="Applied" {% if edit_job and edit_job.status == 'Applied' %}selected{% endif %}>Applied</option>
|
| 161 |
+
<option value="Interviewing" {% if edit_job and edit_job.status == 'Interviewing' %}selected{% endif %}>Interviewing</option>
|
| 162 |
+
<option value="Rejected" {% if edit_job and edit_job.status == 'Rejected' %}selected{% endif %}>Rejected</option>
|
| 163 |
+
<option value="On Hold" {% if edit_job and edit_job.status == 'On Hold' %}selected{% endif %}>On Hold</option>
|
| 164 |
+
<option value="Offer" {% if edit_job and edit_job.status == 'Offer' %}selected{% endif %}>Offer</option>
|
| 165 |
+
</select>
|
| 166 |
+
</div>
|
| 167 |
+
<div class="mb-3">
|
| 168 |
+
<label for="interview_details" class="form-label">Interview Details</label>
|
| 169 |
+
<textarea class="form-control" id="interview_details" name="interview_details">{{ edit_job.interview_details if edit_job else '' }}</textarea>
|
| 170 |
+
</div>
|
| 171 |
+
<div class="mb-3">
|
| 172 |
+
<label for="comments" class="form-label">Comments</label>
|
| 173 |
+
<textarea class="form-control" id="comments" name="comments">{{ edit_job.comments if edit_job else '' }}</textarea>
|
| 174 |
+
</div>
|
| 175 |
+
<div class="mb-3">
|
| 176 |
+
<label for="link" class="form-label">Link</label>
|
| 177 |
+
<input type="url" class="form-control" id="link" name="link" value="{{ edit_job.link if edit_job else '' }}">
|
| 178 |
+
</div>
|
| 179 |
+
<div class="mb-3">
|
| 180 |
+
<label for="job_description" class="form-label">Job Description</label>
|
| 181 |
+
<textarea class="form-control" id="job_description" name="job_description">{{ edit_job.job_description if edit_job else '' }}</textarea>
|
| 182 |
+
</div>
|
| 183 |
+
<button type="submit" class="btn btn-primary">{% if edit_job %}Update Job{% else %}Add Job{% endif %}</button>
|
| 184 |
+
</form>
|
| 185 |
+
</div>
|
| 186 |
+
|
| 187 |
+
<!-- PrepMe Tab -->
|
| 188 |
+
<div class="tab-pane fade" id="prepme" role="tabpanel" aria-labelledby="prepme-tab">
|
| 189 |
+
<h2 class="mt-4">PrepMe Chatbot</h2>
|
| 190 |
+
<div class="card">
|
| 191 |
+
<div class="card-body">
|
| 192 |
+
{% if jobs %}
|
| 193 |
+
<h5 class="card-title">Job: {{ jobs[0].company }} - {{ jobs[0].position }}</h5>
|
| 194 |
+
<p class="card-text">Job Description: {{ jobs[0].job_description }}</p>
|
| 195 |
+
{% else %}
|
| 196 |
+
<p>No jobs available.</p>
|
| 197 |
+
{% endif %}
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
<div class="chat-container mt-4">
|
| 201 |
+
<div id="chat-box" class="border p-3" style="height: 300px; overflow-y: scroll;">
|
| 202 |
+
<!-- Chat messages will appear here -->
|
| 203 |
+
</div>
|
| 204 |
+
<div class="input-group mt-3">
|
| 205 |
+
<input type="text" id="user-input" class="form-control" placeholder="Type your message here...">
|
| 206 |
+
<button id="send-btn" class="btn btn-primary">Send</button>
|
| 207 |
+
</div>
|
| 208 |
+
</div>
|
| 209 |
+
</div>
|
| 210 |
+
</div>
|
| 211 |
+
</div>
|
| 212 |
+
|
| 213 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
|
| 214 |
+
<!-- No custom JS needed for tab switching; Bootstrap handles it automatically -->
|
| 215 |
+
</body>
|
| 216 |
+
</html>
|
templates/prepme.html
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>PrepMe Chatbot</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div class="container mt-5">
|
| 11 |
+
<h1 class="text-center">PrepMe Chatbot</h1>
|
| 12 |
+
<div class="card">
|
| 13 |
+
<div class="card-body" style="max-height: 300px; overflow-y: auto;">
|
| 14 |
+
<h5 class="card-title">Job: {{ job.company }} - {{ job.position }}</h5>
|
| 15 |
+
<p class="card-text">Job Description: {{ job.job_description }}</p>
|
| 16 |
+
<p class="card-text">Resume: {{ initial_context.split('Resume:\n')[1] }}</p>
|
| 17 |
+
</div>
|
| 18 |
+
</div>
|
| 19 |
+
|
| 20 |
+
<div class="input-group mt-3">
|
| 21 |
+
<input type="text" id="user-input" class="form-control" placeholder="Type your message here...">
|
| 22 |
+
<button id="send-btn" class="btn btn-primary">Send</button>
|
| 23 |
+
</div>
|
| 24 |
+
|
| 25 |
+
<div class="chat-container mt-3">
|
| 26 |
+
<div id="chat-box" class="border p-3" style="height: 300px; overflow-y: scroll;">
|
| 27 |
+
<div>Bot: {{ initial_response }}</div>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<script>
|
| 33 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 34 |
+
const chatBox = document.getElementById('chat-box');
|
| 35 |
+
const userInput = document.getElementById('user-input');
|
| 36 |
+
const sendBtn = document.getElementById('send-btn');
|
| 37 |
+
|
| 38 |
+
console.log('[PrepMe] Chat interface loaded:', { chatBox, userInput, sendBtn });
|
| 39 |
+
|
| 40 |
+
async function handleSendClick() {
|
| 41 |
+
const userMessage = userInput.value.trim();
|
| 42 |
+
console.log('[PrepMe] Send button clicked, message:', userMessage);
|
| 43 |
+
if (!userMessage) {
|
| 44 |
+
console.log('[PrepMe] Empty message, ignoring');
|
| 45 |
+
return;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// Show the user's message
|
| 49 |
+
const uDiv = document.createElement('div');
|
| 50 |
+
uDiv.textContent = `You: ${userMessage}`;
|
| 51 |
+
chatBox.appendChild(uDiv);
|
| 52 |
+
userInput.value = '';
|
| 53 |
+
|
| 54 |
+
try {
|
| 55 |
+
console.log('[PrepMe] Sending fetch request to /api/chat');
|
| 56 |
+
const res = await fetch('/api/chat', {
|
| 57 |
+
method: 'POST',
|
| 58 |
+
headers: { 'Content-Type': 'application/json' },
|
| 59 |
+
body: JSON.stringify({ message: userMessage }),
|
| 60 |
+
});
|
| 61 |
+
console.log('[PrepMe] Server response status:', res.status);
|
| 62 |
+
|
| 63 |
+
if (!res.ok) {
|
| 64 |
+
const errText = await res.text();
|
| 65 |
+
console.error('[PrepMe] Server error:', errText);
|
| 66 |
+
throw new Error(`HTTP ${res.status}: ${errText}`);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
const data = await res.json();
|
| 70 |
+
console.log('[PrepMe] Server response data:', data);
|
| 71 |
+
|
| 72 |
+
const bDiv = document.createElement('div');
|
| 73 |
+
bDiv.textContent = `Bot: ${data.response}`;
|
| 74 |
+
chatBox.appendChild(bDiv);
|
| 75 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
| 76 |
+
|
| 77 |
+
} catch (err) {
|
| 78 |
+
console.error('[PrepMe] Chat error:', err);
|
| 79 |
+
const errDiv = document.createElement('div');
|
| 80 |
+
errDiv.textContent = `Error: ${err.message}`;
|
| 81 |
+
errDiv.style.color = 'red';
|
| 82 |
+
chatBox.appendChild(errDiv);
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
sendBtn.addEventListener('click', handleSendClick);
|
| 87 |
+
});
|
| 88 |
+
</script>
|
| 89 |
+
</body>
|
| 90 |
+
</html>
|
templates/prepmeBkp.html
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>PrepMe Chatbot</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<!-- remove this line once you see it! -->
|
| 11 |
+
<div class="container mt-5">
|
| 12 |
+
<h1 class="text-center">PrepMe Chatbot</h1>
|
| 13 |
+
<div class="card">
|
| 14 |
+
<div class="card-body">
|
| 15 |
+
<h5 class="card-title">Job: {{ job.company }} - {{ job.position }}</h5>
|
| 16 |
+
<p class="card-text">Job Description: {{ job.job_description }}</p>
|
| 17 |
+
<p class="card-text">Resume: {{ initial_context.split('Resume:\n')[1] }}</p>
|
| 18 |
+
</div>
|
| 19 |
+
</div>
|
| 20 |
+
|
| 21 |
+
<div class="chat-container mt-4">
|
| 22 |
+
<div id="chat-box" class="border p-3" style="height: 300px; overflow-y: scroll;">
|
| 23 |
+
<div>Bot: {{ initial_response }}</div>
|
| 24 |
+
</div>
|
| 25 |
+
<div class="input-group mt-3">
|
| 26 |
+
<input type="text" id="user-input" class="form-control" placeholder="Type your message here...">
|
| 27 |
+
<button id="send-btn" class="btn btn-primary">Send</button>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<script>
|
| 33 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 34 |
+
const chatBox = document.getElementById('chat-box');
|
| 35 |
+
const userInput = document.getElementById('user-input');
|
| 36 |
+
const sendBtn = document.getElementById('send-btn');
|
| 37 |
+
|
| 38 |
+
console.log('[PrepMe] Chat interface loaded:', { chatBox, userInput, sendBtn });
|
| 39 |
+
|
| 40 |
+
sendBtn.addEventListener('click', async () => {
|
| 41 |
+
const userMessage = userInput.value.trim();
|
| 42 |
+
console.log('[PrepMe] Send button clicked, message:', userMessage);
|
| 43 |
+
if (!userMessage) {
|
| 44 |
+
console.log('[PrepMe] Empty message, ignoring');
|
| 45 |
+
return;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// Show the user's message
|
| 49 |
+
const uDiv = document.createElement('div');
|
| 50 |
+
uDiv.textContent = `You: ${userMessage}`;
|
| 51 |
+
chatBox.appendChild(uDiv);
|
| 52 |
+
userInput.value = '';
|
| 53 |
+
|
| 54 |
+
try {
|
| 55 |
+
console.log('[PrepMe] Sending fetch request to /api/chat');
|
| 56 |
+
const res = await fetch('/api/chat', {
|
| 57 |
+
method: 'POST',
|
| 58 |
+
headers: { 'Content-Type': 'application/json' },
|
| 59 |
+
body: JSON.stringify({ message: userMessage }),
|
| 60 |
+
});
|
| 61 |
+
console.log('[PrepMe] Server response status:', res.status);
|
| 62 |
+
|
| 63 |
+
if (!res.ok) {
|
| 64 |
+
const errText = await res.text();
|
| 65 |
+
console.error('[PrepMe] Server error:', errText);
|
| 66 |
+
throw new Error(`HTTP ${res.status}: ${errText}`);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
const data = await res.json();
|
| 70 |
+
console.log('[PrepMe] Server response data:', data);
|
| 71 |
+
|
| 72 |
+
const bDiv = document.createElement('div');
|
| 73 |
+
bDiv.textContent = `Bot: ${data.response}`;
|
| 74 |
+
chatBox.appendChild(bDiv);
|
| 75 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
| 76 |
+
|
| 77 |
+
} catch (err) {
|
| 78 |
+
console.error('[PrepMe] Chat error:', err);
|
| 79 |
+
const errDiv = document.createElement('div');
|
| 80 |
+
errDiv.textContent = `Error: ${err.message}`;
|
| 81 |
+
errDiv.style.color = 'red';
|
| 82 |
+
chatBox.appendChild(errDiv);
|
| 83 |
+
}
|
| 84 |
+
});
|
| 85 |
+
});
|
| 86 |
+
</script>
|
| 87 |
+
|
| 88 |
+
</body>
|
| 89 |
+
</html>
|