Spaces:
Sleeping
Sleeping
File size: 1,396 Bytes
36bd0e2 3d04e63 36bd0e2 3d04e63 36bd0e2 3d04e63 36bd0e2 3d04e63 36bd0e2 | 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 | <!DOCTYPE html>
<html>
<head>
<title>Ticker Checker</title>
<style>
body { font-family: Arial; margin: 40px; }
input { padding: 8px; width: 200px; }
button { padding: 8px 12px; }
#result { margin-top: 20px; font-size: 18px; }
</style>
</head>
<body>
<h2>Check if a Ticker Exists</h2>
<input id="tickerInput" type="text" placeholder="Enter ticker (e.g., AAPL)">
<button onclick="checkTicker()">Check</button>
<div id="result"></div>
<script>
async function checkTicker() {
const ticker = document.getElementById("tickerInput").value.trim().toUpperCase();
const resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // clear previous result
if (!ticker) {
resultDiv.innerHTML = `<span style="color: red;">Please enter a ticker.</span>`;
return;
}
try {
const response = await fetch(`/check/${ticker}`);
const data = await response.json();
if (data.exists) {
resultDiv.innerHTML = `<span style="color: green;">✔ ${data.message}</span>`;
} else {
resultDiv.innerHTML = `<span style="color: red;">✘ ${data.message}</span>`;
}
} catch (err) {
resultDiv.innerHTML = `<span style="color: red;">Error connecting to server.</span>`;
console.error("Network error:", err);
}
}
</script>
</body>
</html>
|