| <!DOCTYPE html>
|
| <html lang="en">
|
| <head>
|
| <meta charset="UTF-8">
|
| <title>Hybrid URL Spam Checker</title>
|
| <style>
|
| body {
|
| font-family: Arial, sans-serif;
|
| background: #f7f9fc;
|
| display: flex;
|
| justify-content: center;
|
| align-items: center;
|
| height: 100vh;
|
| }
|
| .container {
|
| background: #ffffff;
|
| padding: 30px;
|
| border-radius: 12px;
|
| box-shadow: 0 4px 20px rgba(0,0,0,0.1);
|
| width: 400px;
|
| text-align: center;
|
| }
|
| input {
|
| padding: 10px;
|
| width: 90%;
|
| margin-bottom: 15px;
|
| border-radius: 6px;
|
| border: 1px solid #ccc;
|
| }
|
| button {
|
| padding: 10px 20px;
|
| border: none;
|
| background-color: #007BFF;
|
| color: white;
|
| border-radius: 6px;
|
| cursor: pointer;
|
| }
|
| .result {
|
| margin-top: 20px;
|
| font-size: 16px;
|
| font-weight: bold;
|
| }
|
| .safe {
|
| color: green;
|
| }
|
| .spam {
|
| color: red;
|
| }
|
| </style>
|
| </head>
|
| <body>
|
| <div class="container">
|
| <h2>π Hybrid URL Spam Checker (NB + DT + SVM)</h2>
|
| <input type="text" id="urlInput" placeholder="Enter URL to check" />
|
| <button onclick="checkURL()">Check</button>
|
| <div class="result" id="resultText"></div>
|
| </div>
|
|
|
| <script>
|
| async function checkURL() {
|
| const url = document.getElementById("urlInput").value;
|
| const resultText = document.getElementById("resultText");
|
|
|
| if (!url) {
|
| resultText.innerHTML = "β Please enter a URL.";
|
| resultText.className = "result spam";
|
| return;
|
| }
|
|
|
| resultText.innerHTML = "β³ Checking...";
|
| resultText.className = "result";
|
|
|
| try {
|
| const response = await fetch("/predict", {
|
| method: "POST",
|
| headers: {
|
| "Content-Type": "application/json"
|
| },
|
| body: JSON.stringify({ url: url })
|
| });
|
|
|
| const data = await response.json();
|
|
|
| if (data.error) {
|
| resultText.innerHTML = `β Error: ${data.error}`;
|
| resultText.className = "result spam";
|
| } else if (data.prediction === 1) {
|
| resultText.innerHTML = `π« SPAM / PHISHING<br>π Reason: ${data.reason}`;
|
| resultText.className = "result spam";
|
| } else {
|
| resultText.innerHTML = `β
SAFE<br>π Reason: ${data.reason}`;
|
| resultText.className = "result safe";
|
| }
|
|
|
| } catch (error) {
|
| resultText.innerHTML = `β Server Error: ${error}`;
|
| resultText.className = "result spam";
|
| }
|
| }
|
| </script>
|
| </body>
|
| </html>
|
|
|