Spaces:
Running
Running
File size: 8,017 Bytes
3ef2ec7 2cd773c c2bedb6 3ef2ec7 2cd773c 3ef2ec7 7728cb8 3ef2ec7 |
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Job Search API</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
border-radius: 12px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
padding: 40px;
max-width: 600px;
width: 100%;
}
h1 {
color: #333;
margin-bottom: 30px;
font-size: 28px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #555;
font-weight: 500;
}
input {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 6px;
font-size: 16px;
transition: border-color 0.3s;
}
input:focus {
outline: none;
border-color: #667eea;
}
button {
width: 100%;
padding: 14px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 6px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
button:active {
transform: translateY(0);
}
button:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
#result {
margin-top: 30px;
padding: 20px;
background: #f5f5f5;
border-radius: 6px;
display: none;
max-height: 400px;
overflow-y: auto;
}
#result.show {
display: block;
}
.error {
color: #d32f2f;
}
.success {
color: #2e7d32;
}
pre {
white-space: pre-wrap;
word-wrap: break-word;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h1>Job Search API</h1>
<form id="searchForm">
<div class="form-group">
<label for="searchPhrase">Search Phrase</label>
<input type="text" id="searchPhrase" name="searchPhrase" value="Basis Ed Louisiana" required>
</div>
<div class="form-group">
<label for="pageStartIndex">Page Start Index</label>
<input type="number" id="pageStartIndex" name="pageStartIndex" value="11" min="0" required>
</div>
<div class="form-group">
<label for="pageEndIndex">Page End Index</label>
<input type="number" id="pageEndIndex" name="pageEndIndex" value="20" min="0" required>
</div>
<button type="submit" id="submitBtn">Search Jobs</button>
</form>
<div id="result"></div>
</div>
<script>
const form = document.getElementById('searchForm');
const resultDiv = document.getElementById('result');
const submitBtn = document.getElementById('submitBtn');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const searchPhrase = document.getElementById('searchPhrase').value;
const pageStartIndex = parseInt(document.getElementById('pageStartIndex').value);
const pageEndIndex = parseInt(document.getElementById('pageEndIndex').value);
const requestBody = {
searchPhrase: searchPhrase,
filters: [
{ name: "positionAreas", filters: [] },
{ name: "gradeLevels", filters: [] },
{ name: "jobTypes", filters: [] }
],
pageStartIndex: pageStartIndex,
pageEndIndex: pageEndIndex
};
submitBtn.disabled = true;
submitBtn.textContent = 'Searching...';
resultDiv.classList.add('show');
resultDiv.innerHTML = '<p>Loading...</p>';
try {
// Using free CORS proxy to bypass CORS restrictions
const proxyUrl = 'https://api.allorigins.win/raw?url=';
const apiUrl = 'https://api.k12jobspot.com/api/Jobs/Search';
const response = await fetch(proxyUrl + encodeURIComponent(apiUrl), {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'User-Agent': 'Mozilla/5.0',
'Origin': 'https://k12jobspot.com',
'Referer': 'https://k12jobspot.com/'
},
body: JSON.stringify(requestBody)
});
const data = await response.json();
if (response.ok) {
resultDiv.innerHTML = `
<h3 class="success">Success!</h3>
<p><strong>Status:</strong> ${response.status}</p>
<p><strong>Response:</strong></p>
<pre>${JSON.stringify(data, null, 2)}</pre>
`;
} else {
resultDiv.innerHTML = `
<h3 class="error">Error</h3>
<p><strong>Status:</strong> ${response.status}</p>
<pre>${JSON.stringify(data, null, 2)}</pre>
`;
}
} catch (error) {
resultDiv.innerHTML = `
<h3 class="error">CORS Error - Request Blocked</h3>
<p>The API doesn't allow direct browser requests. Here's the request info you need:</p>
<h4>Request Details:</h4>
<p><strong>URL:</strong> https://api.k12jobspot.com/api/Jobs/Search</p>
<p><strong>Method:</strong> POST</p>
<p><strong>Headers:</strong></p>
<pre>Content-Type: application/json</pre>
<p><strong>Body:</strong></p>
<pre>${JSON.stringify(requestBody, null, 2)}</pre>
<h4>Solutions:</h4>
<p>1. Use a backend server (Node.js, Python, etc.) to make the request</p>
<p>2. Use a CORS proxy service</p>
<p>3. Use tools like Postman or curl to test the API</p>
<p>4. Copy the curl command below:</p>
<pre>curl -X POST https://api.k12jobspot.com/api/Jobs/Search \\
-H "Content-Type: application/json" \\
-d '${JSON.stringify(requestBody)}'</pre>
`;
} finally {
submitBtn.disabled = false;
submitBtn.textContent = 'Search Jobs';
}
});
</script>
</body>
</html> |