Spaces:
Runtime error
Runtime error
Inder-26 commited on
Commit ·
137da8f
1
Parent(s): 1222ff0
feat: Implement web application for phishing URL detection with new UI, integrated model training, and prediction endpoints, removing old artifacts.
Browse files- Dockerfile +20 -12
- app.py +564 -59
- confusion_matrix.png +0 -0
- networksecurity/components/model_trainer.py +4 -8
- networksecurity/pipeline/training_pipeline.py +2 -2
- precision_recall_curve.png +0 -0
- prediction_output/output.csv +0 -13
- requirements.txt +1 -0
- roc_curve.png +0 -0
- static/css/style.css +1456 -0
- static/js/main.js +271 -0
- templates/index.html +341 -0
- templates/predict.html +224 -15
- templates/single_predict.html +436 -0
- test.py +119 -0
Dockerfile
CHANGED
|
@@ -1,22 +1,30 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
RUN apt-get update &&
|
| 7 |
-
apt-get install -y gcc g++ build-essential && \
|
| 8 |
-
rm -rf /var/lib/apt/lists/*
|
| 9 |
|
|
|
|
| 10 |
COPY requirements.txt .
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# Install awscli separately
|
| 15 |
-
RUN pip install --no-cache-dir awscli
|
| 16 |
-
|
| 17 |
-
# Install project dependencies
|
| 18 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
|
|
|
|
| 20 |
COPY . .
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use official Python runtime as a parent image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies (git is often needed for DagsHub/MLflow)
|
| 8 |
+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Copy requirements file first to leverage Docker cache
|
| 11 |
COPY requirements.txt .
|
| 12 |
|
| 13 |
+
# Install Python dependencies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
+
# Copy the rest of the application code
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
+
# Create necessary directories for potential output
|
| 20 |
+
RUN mkdir -p final_model prediction_output validation_output
|
| 21 |
+
|
| 22 |
+
# Expose the port that Hugging Face Spaces expects (7860)
|
| 23 |
+
EXPOSE 7860
|
| 24 |
+
|
| 25 |
+
# Define environment variable for ensuring stdout is flushed immediately
|
| 26 |
+
ENV PYTHONUNBUFFERED=1
|
| 27 |
+
|
| 28 |
+
# Command to run the application
|
| 29 |
+
# Note: We bind to 0.0.0.0 to enable external access within the container network
|
| 30 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
CHANGED
|
@@ -1,98 +1,603 @@
|
|
| 1 |
-
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
print(mong_db_url)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
from networksecurity.pipeline.training_pipeline import TraningPipeline
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
-
app = FastAPI(
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
| 37 |
app.add_middleware(
|
| 38 |
CORSMiddleware,
|
| 39 |
-
allow_origins=
|
| 40 |
allow_credentials=True,
|
| 41 |
allow_methods=["*"],
|
| 42 |
allow_headers=["*"],
|
| 43 |
)
|
| 44 |
|
| 45 |
-
|
|
|
|
| 46 |
templates = Jinja2Templates(directory="templates")
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
try:
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|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|
-
df["prediction_column"] = y_pred
|
| 84 |
-
print(df["prediction_column"])
|
| 85 |
|
| 86 |
-
os.makedirs("prediction_output", exist_ok=True)
|
| 87 |
-
df.to_csv("prediction_output/output.csv", index=False)
|
| 88 |
-
table_html = df.to_html(classes='table table-striped')
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
except Exception as e:
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
if __name__ == "__main__":
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import numpy as np
|
| 5 |
+
import joblib
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
from typing import Optional
|
| 9 |
|
| 10 |
+
from fastapi import FastAPI, File, UploadFile, Request, HTTPException, Form
|
| 11 |
+
from fastapi.responses import HTMLResponse, FileResponse, JSONResponse
|
| 12 |
+
from fastapi.staticfiles import StaticFiles
|
| 13 |
+
from fastapi.templating import Jinja2Templates
|
| 14 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 15 |
|
| 16 |
+
import uvicorn
|
| 17 |
+
import mlflow
|
| 18 |
+
import dagshub
|
| 19 |
+
import shutil
|
| 20 |
+
from networksecurity.pipeline.training_pipeline import TrainingPipeline
|
| 21 |
|
| 22 |
+
# ============================================================
|
| 23 |
+
# Configuration
|
| 24 |
+
# ============================================================
|
|
|
|
| 25 |
|
| 26 |
+
APP_TITLE = "Network Security - Phishing Detection"
|
| 27 |
+
APP_DESCRIPTION = "ML-powered phishing URL detection system"
|
| 28 |
+
APP_VERSION = "1.0.0"
|
|
|
|
| 29 |
|
| 30 |
+
# Project Links
|
| 31 |
+
GITHUB_URL = "https://github.com/Inder-26/NetworkSecurity"
|
| 32 |
+
DAGSHUB_URL = "https://dagshub.com/Inder-26/NetworkSecurity"
|
| 33 |
+
LINKEDIN_URL = "https://linkedin.com/in/inderjeet" # Update with your actual LinkedIn
|
| 34 |
+
|
| 35 |
+
# Model Paths
|
| 36 |
+
MODEL_PATH = "final_model/model.pkl"
|
| 37 |
+
PREPROCESSOR_PATH = "final_model/preprocessor.pkl"
|
| 38 |
+
|
| 39 |
+
# Initialize DagsHub
|
| 40 |
+
try:
|
| 41 |
+
dagshub.init(repo_owner="Inder-26", repo_name="NetworkSecurity", mlflow=True)
|
| 42 |
+
except Exception as e:
|
| 43 |
+
print(f"⚠️ Error initializing DagsHub: {e}")
|
| 44 |
+
|
| 45 |
+
# Feature Columns (30 features)
|
| 46 |
+
FEATURE_COLUMNS = [
|
| 47 |
+
"having_IP_Address", "URL_Length", "Shortining_Service", "having_At_Symbol",
|
| 48 |
+
"double_slash_redirecting", "Prefix_Suffix", "having_Sub_Domain", "SSLfinal_State",
|
| 49 |
+
"Domain_registeration_length", "Favicon", "port", "HTTPS_token", "Request_URL",
|
| 50 |
+
"URL_of_Anchor", "Links_in_tags", "SFH", "Submitting_to_email", "Abnormal_URL",
|
| 51 |
+
"Redirect", "on_mouseover", "RightClick", "popUpWidnow", "Iframe", "age_of_domain",
|
| 52 |
+
"DNSRecord", "web_traffic", "Page_Rank", "Google_Index", "Links_pointing_to_page",
|
| 53 |
+
"Statistical_report"
|
| 54 |
+
]
|
| 55 |
+
|
| 56 |
+
# Feature descriptions for UI
|
| 57 |
+
FEATURE_INFO = {
|
| 58 |
+
"having_IP_Address": {"group": "URL Structure", "desc": "IP address in URL"},
|
| 59 |
+
"URL_Length": {"group": "URL Structure", "desc": "Length of URL"},
|
| 60 |
+
"Shortining_Service": {"group": "URL Structure", "desc": "URL shortening service used"},
|
| 61 |
+
"having_At_Symbol": {"group": "URL Structure", "desc": "@ symbol in URL"},
|
| 62 |
+
"double_slash_redirecting": {"group": "URL Structure", "desc": "// redirecting"},
|
| 63 |
+
"Prefix_Suffix": {"group": "URL Structure", "desc": "Prefix/suffix in domain"},
|
| 64 |
+
"having_Sub_Domain": {"group": "URL Structure", "desc": "Subdomain presence"},
|
| 65 |
+
"SSLfinal_State": {"group": "Security", "desc": "SSL certificate state"},
|
| 66 |
+
"Domain_registeration_length": {"group": "Domain", "desc": "Domain registration length"},
|
| 67 |
+
"Favicon": {"group": "Security", "desc": "Favicon loaded from external"},
|
| 68 |
+
"port": {"group": "Security", "desc": "Non-standard port"},
|
| 69 |
+
"HTTPS_token": {"group": "Security", "desc": "HTTPS token in domain"},
|
| 70 |
+
"Request_URL": {"group": "Page Content", "desc": "External request URLs"},
|
| 71 |
+
"URL_of_Anchor": {"group": "Page Content", "desc": "Anchor URL analysis"},
|
| 72 |
+
"Links_in_tags": {"group": "Page Content", "desc": "Links in meta/script tags"},
|
| 73 |
+
"SFH": {"group": "Page Content", "desc": "Server Form Handler"},
|
| 74 |
+
"Submitting_to_email": {"group": "Page Content", "desc": "Form submits to email"},
|
| 75 |
+
"Abnormal_URL": {"group": "URL Structure", "desc": "Abnormal URL pattern"},
|
| 76 |
+
"Redirect": {"group": "Page Behavior", "desc": "Redirect count"},
|
| 77 |
+
"on_mouseover": {"group": "Page Behavior", "desc": "onMouseOver events"},
|
| 78 |
+
"RightClick": {"group": "Page Behavior", "desc": "Right-click disabled"},
|
| 79 |
+
"popUpWidnow": {"group": "Page Behavior", "desc": "Pop-up windows"},
|
| 80 |
+
"Iframe": {"group": "Page Behavior", "desc": "Iframe usage"},
|
| 81 |
+
"age_of_domain": {"group": "Domain", "desc": "Domain age"},
|
| 82 |
+
"DNSRecord": {"group": "Domain", "desc": "DNS record exists"},
|
| 83 |
+
"web_traffic": {"group": "Domain", "desc": "Web traffic ranking"},
|
| 84 |
+
"Page_Rank": {"group": "Domain", "desc": "Google PageRank"},
|
| 85 |
+
"Google_Index": {"group": "Domain", "desc": "Indexed by Google"},
|
| 86 |
+
"Links_pointing_to_page": {"group": "Domain", "desc": "External links count"},
|
| 87 |
+
"Statistical_report": {"group": "Security", "desc": "In statistical reports"}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
# Actual Model Metrics from DagsHub experiments
|
| 91 |
+
MODEL_METRICS = {
|
| 92 |
+
"model_name": "Random Forest",
|
| 93 |
+
"accuracy": 0.0,
|
| 94 |
+
"f1_score": 0.0,
|
| 95 |
+
"precision": 0.0,
|
| 96 |
+
"recall": 0.0,
|
| 97 |
+
"training_date": "N/A"
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
# All model comparison data
|
| 101 |
+
ALL_MODELS = []
|
| 102 |
+
|
| 103 |
+
def get_latest_metrics():
|
| 104 |
+
"""Fetch latest metrics from DagsHub/MLflow"""
|
| 105 |
+
global MODEL_METRICS, ALL_MODELS
|
| 106 |
+
try:
|
| 107 |
+
# Search for all successful runs
|
| 108 |
+
runs = mlflow.search_runs()
|
| 109 |
+
|
| 110 |
+
if runs.empty:
|
| 111 |
+
print("⚠️ No MLflow runs found.")
|
| 112 |
+
return
|
| 113 |
+
|
| 114 |
+
# Process all runs for the table
|
| 115 |
+
all_models_data = []
|
| 116 |
+
best_f1 = -1
|
| 117 |
+
best_run = None
|
| 118 |
+
|
| 119 |
+
for _, run in runs.iterrows():
|
| 120 |
+
# Extract metrics
|
| 121 |
+
accuracy = run.get("metrics.test_accuracy", 0) # Fallback if specific metric missing
|
| 122 |
+
f1 = run.get("metrics.test_f1", 0)
|
| 123 |
+
precision = run.get("metrics.test_precision", 0)
|
| 124 |
+
recall = run.get("metrics.test_recall", 0)
|
| 125 |
+
|
| 126 |
+
# Extract tags/params
|
| 127 |
+
model_name = run.get("tags.model_name", run.get("params.model_name", "Unknown Model"))
|
| 128 |
+
|
| 129 |
+
# Check if this is the best model so far
|
| 130 |
+
if f1 > best_f1:
|
| 131 |
+
best_f1 = f1
|
| 132 |
+
best_run = {
|
| 133 |
+
"model_name": model_name,
|
| 134 |
+
"accuracy": round(accuracy, 4),
|
| 135 |
+
"f1_score": round(f1, 4),
|
| 136 |
+
"precision": round(precision, 4),
|
| 137 |
+
"recall": round(recall, 4),
|
| 138 |
+
"training_date": run.get("start_time", datetime.now()).strftime("%Y-%m-%d") if isinstance(run.get("start_time"), datetime) else str(run.get("start_time"))[:10]
|
| 139 |
+
}
|
| 140 |
|
| 141 |
+
all_models_data.append({
|
| 142 |
+
"name": model_name,
|
| 143 |
+
"accuracy": round(accuracy, 4),
|
| 144 |
+
"f1": round(f1, 4),
|
| 145 |
+
"precision": round(precision, 4),
|
| 146 |
+
"recall": round(recall, 4),
|
| 147 |
+
"best": False # Will set best later
|
| 148 |
+
})
|
| 149 |
+
|
| 150 |
+
# Update global variables
|
| 151 |
+
if best_run:
|
| 152 |
+
MODEL_METRICS = best_run
|
| 153 |
+
# Mark the best model in the list
|
| 154 |
+
for m in all_models_data:
|
| 155 |
+
if m["name"] == best_run["model_name"] and m["f1"] == best_run["f1_score"]:
|
| 156 |
+
m["best"] = True
|
| 157 |
+
|
| 158 |
+
ALL_MODELS = sorted(all_models_data, key=lambda x: x['f1'], reverse=True)
|
| 159 |
+
print(f"✅ Metrics updated from MLflow. Best model: {best_run['model_name']}")
|
| 160 |
|
| 161 |
+
except Exception as e:
|
| 162 |
+
print(f"❌ Error fetching MLflow metrics: {e}")
|
| 163 |
|
| 164 |
+
# Fetch initial metrics
|
| 165 |
+
get_latest_metrics()
|
| 166 |
|
| 167 |
+
# ============================================================
|
| 168 |
+
# Initialize FastAPI App
|
| 169 |
+
# ============================================================
|
| 170 |
|
| 171 |
+
app = FastAPI(
|
| 172 |
+
title=APP_TITLE,
|
| 173 |
+
description=APP_DESCRIPTION,
|
| 174 |
+
version=APP_VERSION,
|
| 175 |
+
docs_url="/api/docs",
|
| 176 |
+
redoc_url="/api/redoc"
|
| 177 |
+
)
|
| 178 |
|
| 179 |
+
# CORS Middleware
|
| 180 |
app.add_middleware(
|
| 181 |
CORSMiddleware,
|
| 182 |
+
allow_origins=["*"],
|
| 183 |
allow_credentials=True,
|
| 184 |
allow_methods=["*"],
|
| 185 |
allow_headers=["*"],
|
| 186 |
)
|
| 187 |
|
| 188 |
+
# Static Files and Templates
|
| 189 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 190 |
templates = Jinja2Templates(directory="templates")
|
| 191 |
|
| 192 |
+
# ============================================================
|
| 193 |
+
# Load Models
|
| 194 |
+
# ============================================================
|
|
|
|
| 195 |
|
| 196 |
+
def load_models():
|
| 197 |
+
"""Load the trained model and preprocessor"""
|
| 198 |
try:
|
| 199 |
+
if os.path.exists(MODEL_PATH) and os.path.exists(PREPROCESSOR_PATH):
|
| 200 |
+
model = joblib.load(MODEL_PATH)
|
| 201 |
+
preprocessor = joblib.load(PREPROCESSOR_PATH)
|
| 202 |
+
print("✅ Models loaded successfully!")
|
| 203 |
+
return model, preprocessor
|
| 204 |
+
else:
|
| 205 |
+
print("⚠️ Model files not found. Running in demo mode.")
|
| 206 |
+
return None, None
|
| 207 |
except Exception as e:
|
| 208 |
+
print(f"❌ Error loading models: {e}")
|
| 209 |
+
return None, None
|
| 210 |
+
|
| 211 |
+
model, preprocessor = load_models()
|
| 212 |
+
|
| 213 |
+
# ============================================================
|
| 214 |
+
# Utility Functions
|
| 215 |
+
# ============================================================
|
| 216 |
+
|
| 217 |
+
def generate_sample_data(n_samples: int = 5) -> pd.DataFrame:
|
| 218 |
+
"""Generate sample input data for testing"""
|
| 219 |
+
np.random.seed(42)
|
| 220 |
+
data = {}
|
| 221 |
+
for col in FEATURE_COLUMNS:
|
| 222 |
+
data[col] = np.random.choice([-1, 0, 1], size=n_samples)
|
| 223 |
+
return pd.DataFrame(data)
|
| 224 |
+
|
| 225 |
+
def predict_single(features: dict) -> dict:
|
| 226 |
+
"""Make prediction for a single sample"""
|
| 227 |
+
if model is None or preprocessor is None:
|
| 228 |
+
# Demo mode - return random prediction
|
| 229 |
+
prediction = np.random.choice([0, 1])
|
| 230 |
+
confidence = np.random.uniform(0.7, 0.99)
|
| 231 |
+
else:
|
| 232 |
+
df = pd.DataFrame([features])
|
| 233 |
+
X_transformed = preprocessor.transform(df)
|
| 234 |
+
prediction = model.predict(X_transformed)[0]
|
| 235 |
+
|
| 236 |
+
try:
|
| 237 |
+
proba = model.predict_proba(X_transformed)[0]
|
| 238 |
+
confidence = float(max(proba))
|
| 239 |
+
except:
|
| 240 |
+
confidence = 0.95
|
| 241 |
+
|
| 242 |
+
return {
|
| 243 |
+
"prediction": int(prediction),
|
| 244 |
+
"label": "Phishing" if prediction == 0 else "Legitimate",
|
| 245 |
+
"confidence": round(confidence * 100, 2),
|
| 246 |
+
"is_threat": prediction == 0
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
def predict_batch(df: pd.DataFrame) -> tuple:
|
| 250 |
+
"""Make predictions for batch data"""
|
| 251 |
+
X = df[FEATURE_COLUMNS]
|
| 252 |
+
|
| 253 |
+
if model is None or preprocessor is None:
|
| 254 |
+
# Demo mode
|
| 255 |
+
predictions = np.random.choice([0, 1], size=len(df))
|
| 256 |
+
confidence = np.random.uniform(0.7, 0.99, size=len(df))
|
| 257 |
+
else:
|
| 258 |
+
X_transformed = preprocessor.transform(X)
|
| 259 |
+
predictions = model.predict(X_transformed)
|
| 260 |
+
|
| 261 |
+
try:
|
| 262 |
+
probabilities = model.predict_proba(X_transformed)
|
| 263 |
+
confidence = np.max(probabilities, axis=1)
|
| 264 |
+
except:
|
| 265 |
+
confidence = np.ones(len(predictions)) * 0.95
|
| 266 |
+
|
| 267 |
+
return predictions, confidence
|
| 268 |
+
|
| 269 |
+
# ============================================================
|
| 270 |
+
# Routes
|
| 271 |
+
# ============================================================
|
| 272 |
+
|
| 273 |
+
@app.get("/", response_class=HTMLResponse)
|
| 274 |
+
async def home(request: Request):
|
| 275 |
+
"""Home page with upload interface"""
|
| 276 |
+
# Refresh metrics on page load
|
| 277 |
+
get_latest_metrics()
|
| 278 |
+
|
| 279 |
+
return templates.TemplateResponse(
|
| 280 |
+
"index.html",
|
| 281 |
+
{
|
| 282 |
+
"request": request,
|
| 283 |
+
"title": APP_TITLE,
|
| 284 |
+
"github_url": GITHUB_URL,
|
| 285 |
+
"dagshub_url": DAGSHUB_URL,
|
| 286 |
+
"linkedin_url": LINKEDIN_URL,
|
| 287 |
+
"metrics": MODEL_METRICS,
|
| 288 |
+
"all_models": ALL_MODELS,
|
| 289 |
+
"feature_count": len(FEATURE_COLUMNS),
|
| 290 |
+
"features": FEATURE_COLUMNS,
|
| 291 |
+
"feature_info": FEATURE_INFO
|
| 292 |
+
}
|
| 293 |
+
)
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
@app.get("/manual", response_class=HTMLResponse)
|
| 297 |
+
async def manual_input(request: Request):
|
| 298 |
+
"""Manual input form page"""
|
| 299 |
+
return templates.TemplateResponse(
|
| 300 |
+
"single_predict.html",
|
| 301 |
+
{
|
| 302 |
+
"request": request,
|
| 303 |
+
"title": "Manual Prediction",
|
| 304 |
+
"features": FEATURE_COLUMNS,
|
| 305 |
+
"feature_info": FEATURE_INFO,
|
| 306 |
+
"github_url": GITHUB_URL,
|
| 307 |
+
"dagshub_url": DAGSHUB_URL,
|
| 308 |
+
"linkedin_url": LINKEDIN_URL
|
| 309 |
+
}
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
|
| 313 |
+
@app.get("/health")
|
| 314 |
+
async def health_check():
|
| 315 |
+
"""Health check endpoint"""
|
| 316 |
+
return {
|
| 317 |
+
"status": "healthy",
|
| 318 |
+
"model_loaded": model is not None,
|
| 319 |
+
"preprocessor_loaded": preprocessor is not None,
|
| 320 |
+
"version": APP_VERSION
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
@app.get("/api/features")
|
| 325 |
+
async def get_features():
|
| 326 |
+
"""Return list of required features"""
|
| 327 |
+
return {
|
| 328 |
+
"features": FEATURE_COLUMNS,
|
| 329 |
+
"count": len(FEATURE_COLUMNS),
|
| 330 |
+
"info": FEATURE_INFO
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
@app.get("/api/metrics")
|
| 335 |
+
async def get_metrics():
|
| 336 |
+
"""Return model performance metrics"""
|
| 337 |
+
return {
|
| 338 |
+
"best_model": MODEL_METRICS,
|
| 339 |
+
"all_models": ALL_MODELS
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
@app.get("/download/sample")
|
| 344 |
+
async def download_sample():
|
| 345 |
+
"""Download sample CSV file"""
|
| 346 |
+
sample_path = "valid_data/test.csv"
|
| 347 |
+
|
| 348 |
+
if not os.path.exists(sample_path):
|
| 349 |
+
# Fallback if specific file not found
|
| 350 |
+
return JSONResponse(status_code=404, content={"message": "Sample file not found at valid_data/test.csv"})
|
| 351 |
+
|
| 352 |
+
return FileResponse(
|
| 353 |
+
sample_path,
|
| 354 |
+
media_type="text/csv",
|
| 355 |
+
filename="sample_phishing_data.csv"
|
| 356 |
+
)
|
| 357 |
|
| 358 |
|
| 359 |
@app.post("/predict")
|
| 360 |
+
async def predict(request: Request, file: UploadFile = File(...)):
|
| 361 |
+
"""Handle file upload and return predictions"""
|
| 362 |
+
|
| 363 |
+
# Validate file type
|
| 364 |
+
if not file.filename.endswith('.csv'):
|
| 365 |
+
raise HTTPException(
|
| 366 |
+
status_code=400,
|
| 367 |
+
detail="Please upload a CSV file"
|
| 368 |
+
)
|
| 369 |
+
|
| 370 |
try:
|
| 371 |
+
# Read uploaded file
|
| 372 |
df = pd.read_csv(file.file)
|
| 373 |
+
original_df = df.copy()
|
| 374 |
+
|
| 375 |
+
# Validate columns
|
| 376 |
+
missing_cols = set(FEATURE_COLUMNS) - set(df.columns)
|
| 377 |
+
if missing_cols:
|
| 378 |
+
raise HTTPException(
|
| 379 |
+
status_code=400,
|
| 380 |
+
detail=f"Missing columns: {', '.join(sorted(missing_cols))}"
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
# Make predictions
|
| 384 |
+
predictions, confidence = predict_batch(df)
|
| 385 |
+
|
| 386 |
+
# Map predictions to labels
|
| 387 |
+
prediction_labels = ["⚠️ Phishing" if p == 0 else "🔒 Legitimate" for p in predictions]
|
| 388 |
+
|
| 389 |
+
# Create results dataframe
|
| 390 |
+
results_df = original_df.copy()
|
| 391 |
+
results_df["Prediction"] = predictions
|
| 392 |
+
results_df["Label"] = prediction_labels
|
| 393 |
+
results_df["Confidence"] = (confidence * 100).round(2)
|
| 394 |
+
|
| 395 |
+
# Save results
|
| 396 |
+
os.makedirs("prediction_output", exist_ok=True)
|
| 397 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 398 |
+
output_filename = f"predictions_{timestamp}.csv"
|
| 399 |
+
output_path = f"prediction_output/{output_filename}"
|
| 400 |
+
results_df.to_csv(output_path, index=False)
|
| 401 |
+
|
| 402 |
+
# Calculate summary
|
| 403 |
+
total = len(predictions)
|
| 404 |
+
# 0 is Phishing (mapped from -1), 1 is Legitimate
|
| 405 |
+
phishing_count = int(np.sum(predictions == 0))
|
| 406 |
+
legitimate_count = total - phishing_count
|
| 407 |
+
|
| 408 |
+
# Prepare display columns (show first 5 features + results)
|
| 409 |
+
display_columns = FEATURE_COLUMNS[:5] + ["Prediction", "Label", "Confidence"]
|
| 410 |
+
|
| 411 |
+
return templates.TemplateResponse(
|
| 412 |
+
"predict.html",
|
| 413 |
+
{
|
| 414 |
+
"request": request,
|
| 415 |
+
"title": "Prediction Results",
|
| 416 |
+
"results": results_df.to_dict(orient="records"),
|
| 417 |
+
"summary": {
|
| 418 |
+
"total": total,
|
| 419 |
+
"phishing": phishing_count,
|
| 420 |
+
"legitimate": legitimate_count,
|
| 421 |
+
"phishing_percent": round(phishing_count / total * 100, 1) if total > 0 else 0
|
| 422 |
+
},
|
| 423 |
+
"output_filename": output_filename,
|
| 424 |
+
"columns": display_columns,
|
| 425 |
+
"github_url": GITHUB_URL,
|
| 426 |
+
"dagshub_url": DAGSHUB_URL,
|
| 427 |
+
"linkedin_url": LINKEDIN_URL
|
| 428 |
+
}
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
except HTTPException:
|
| 432 |
+
raise
|
| 433 |
+
except Exception as e:
|
| 434 |
+
raise HTTPException(
|
| 435 |
+
status_code=500,
|
| 436 |
+
detail=f"Prediction error: {str(e)}"
|
| 437 |
+
)
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
@app.post("/api/predict/single")
|
| 441 |
+
async def predict_single_api(request: Request):
|
| 442 |
+
"""Handle single prediction from form (API)"""
|
| 443 |
+
try:
|
| 444 |
+
form_data = await request.form()
|
| 445 |
+
|
| 446 |
+
# Build feature dictionary
|
| 447 |
+
features = {}
|
| 448 |
+
for col in FEATURE_COLUMNS:
|
| 449 |
+
value = form_data.get(col, "0")
|
| 450 |
+
try:
|
| 451 |
+
features[col] = int(value) if value else 0
|
| 452 |
+
except ValueError:
|
| 453 |
+
features[col] = 0
|
| 454 |
+
|
| 455 |
+
# Make prediction
|
| 456 |
+
result = predict_single(features)
|
| 457 |
+
|
| 458 |
+
def convert_numpy(obj):
|
| 459 |
+
if isinstance(obj, dict):
|
| 460 |
+
return {k: convert_numpy(v) for k, v in obj.items()}
|
| 461 |
+
elif isinstance(obj, list):
|
| 462 |
+
return [convert_numpy(v) for v in obj]
|
| 463 |
+
elif hasattr(obj, 'item'): # Numpy scalars
|
| 464 |
+
return obj.item()
|
| 465 |
+
elif hasattr(obj, 'tolist'): # Numpy arrays
|
| 466 |
+
return obj.tolist()
|
| 467 |
+
return obj
|
| 468 |
+
|
| 469 |
+
# Ensure result is JSON serializable
|
| 470 |
+
clean_result = convert_numpy(result)
|
| 471 |
+
|
| 472 |
+
return JSONResponse(clean_result)
|
| 473 |
+
|
| 474 |
+
except Exception as e:
|
| 475 |
+
print(f"Prediction Error: {e}") # Log error to console
|
| 476 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 477 |
|
|
|
|
|
|
|
| 478 |
|
| 479 |
+
@app.post("/predict/single", response_class=HTMLResponse)
|
| 480 |
+
async def predict_single_form(request: Request):
|
| 481 |
+
"""Handle single prediction from form (HTML response)"""
|
| 482 |
+
try:
|
| 483 |
+
form_data = await request.form()
|
| 484 |
+
|
| 485 |
+
# Build feature dictionary
|
| 486 |
+
features = {}
|
| 487 |
+
for col in FEATURE_COLUMNS:
|
| 488 |
+
value = form_data.get(col, "0")
|
| 489 |
+
try:
|
| 490 |
+
features[col] = int(value) if value else 0
|
| 491 |
+
except ValueError:
|
| 492 |
+
features[col] = 0
|
| 493 |
+
|
| 494 |
+
# Make prediction
|
| 495 |
+
result = predict_single(features)
|
| 496 |
+
|
| 497 |
+
return templates.TemplateResponse(
|
| 498 |
+
"single_predict.html",
|
| 499 |
+
{
|
| 500 |
+
"request": request,
|
| 501 |
+
"title": "Prediction Result",
|
| 502 |
+
"features": FEATURE_COLUMNS,
|
| 503 |
+
"feature_info": FEATURE_INFO,
|
| 504 |
+
"result": result,
|
| 505 |
+
"input_values": features,
|
| 506 |
+
"github_url": GITHUB_URL,
|
| 507 |
+
"dagshub_url": DAGSHUB_URL,
|
| 508 |
+
"linkedin_url": LINKEDIN_URL
|
| 509 |
+
}
|
| 510 |
)
|
| 511 |
+
|
| 512 |
+
except Exception as e:
|
| 513 |
+
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
| 514 |
|
|
|
|
|
|
|
|
|
|
| 515 |
|
| 516 |
+
@app.get("/download/results/{filename}")
|
| 517 |
+
async def download_results(filename: str):
|
| 518 |
+
"""Download prediction results"""
|
| 519 |
+
file_path = f"prediction_output/{filename}"
|
| 520 |
+
if os.path.exists(file_path):
|
| 521 |
+
return FileResponse(
|
| 522 |
+
file_path,
|
| 523 |
+
media_type="text/csv",
|
| 524 |
+
filename=filename
|
| 525 |
+
)
|
| 526 |
+
raise HTTPException(status_code=404, detail="File not found")
|
| 527 |
|
| 528 |
|
| 529 |
+
@app.post("/api/reload-model")
|
| 530 |
+
async def reload_model():
|
| 531 |
+
"""Force reload of the model and metrics"""
|
| 532 |
+
global model, preprocessor
|
| 533 |
+
try:
|
| 534 |
+
model, preprocessor = load_models()
|
| 535 |
+
get_latest_metrics()
|
| 536 |
+
|
| 537 |
+
status = "success" if model is not None else "failed"
|
| 538 |
+
return {
|
| 539 |
+
"status": status,
|
| 540 |
+
"message": "Model reload attempted",
|
| 541 |
+
"model_loaded": model is not None,
|
| 542 |
+
"metrics_updated": True
|
| 543 |
+
}
|
| 544 |
except Exception as e:
|
| 545 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
@app.post("/api/train")
|
| 549 |
+
async def train_model():
|
| 550 |
+
"""Trigger model training"""
|
| 551 |
+
try:
|
| 552 |
+
pipeline = TrainingPipeline()
|
| 553 |
+
pipeline.run_pipeline()
|
| 554 |
+
|
| 555 |
+
# Reload model and metrics
|
| 556 |
+
global model, preprocessor
|
| 557 |
+
model, preprocessor = load_models()
|
| 558 |
+
get_latest_metrics()
|
| 559 |
+
|
| 560 |
+
return {
|
| 561 |
+
"status": "success",
|
| 562 |
+
"message": "Training completed successfully"
|
| 563 |
+
}
|
| 564 |
+
except Exception as e:
|
| 565 |
+
raise HTTPException(status_code=500, detail=str(e))
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
# ============================================================
|
| 569 |
+
# Error Handlers
|
| 570 |
+
# ============================================================
|
| 571 |
+
|
| 572 |
+
@app.exception_handler(404)
|
| 573 |
+
async def not_found_handler(request: Request, exc):
|
| 574 |
+
return templates.TemplateResponse(
|
| 575 |
+
"index.html",
|
| 576 |
+
{
|
| 577 |
+
"request": request,
|
| 578 |
+
"title": APP_TITLE,
|
| 579 |
+
"error": "Page not found",
|
| 580 |
+
"github_url": GITHUB_URL,
|
| 581 |
+
"dagshub_url": DAGSHUB_URL,
|
| 582 |
+
"linkedin_url": LINKEDIN_URL,
|
| 583 |
+
"metrics": MODEL_METRICS,
|
| 584 |
+
"all_models": ALL_MODELS,
|
| 585 |
+
"feature_count": len(FEATURE_COLUMNS),
|
| 586 |
+
"features": FEATURE_COLUMNS,
|
| 587 |
+
"feature_info": FEATURE_INFO
|
| 588 |
+
},
|
| 589 |
+
status_code=404
|
| 590 |
+
)
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
# ============================================================
|
| 594 |
+
# Run Server
|
| 595 |
+
# ============================================================
|
| 596 |
|
| 597 |
if __name__ == "__main__":
|
| 598 |
+
uvicorn.run(
|
| 599 |
+
"app:app",
|
| 600 |
+
host="0.0.0.0",
|
| 601 |
+
port=8000,
|
| 602 |
+
reload=False
|
| 603 |
+
)
|
confusion_matrix.png
DELETED
|
Binary file (14.4 kB)
|
|
|
networksecurity/components/model_trainer.py
CHANGED
|
@@ -42,12 +42,8 @@ from sklearn.metrics import (
|
|
| 42 |
)
|
| 43 |
|
| 44 |
# ---------------- Dagshub + MLflow ----------------
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
repo_owner="Inder-26",
|
| 48 |
-
repo_name="NetworkSecurity",
|
| 49 |
-
mlflow=True,
|
| 50 |
-
)
|
| 51 |
|
| 52 |
|
| 53 |
# ---------------- Helper: log visual artifacts ----------------
|
|
@@ -175,7 +171,7 @@ class ModelTrainer:
|
|
| 175 |
self.data_transformation_artifact.transformed_object_file_path
|
| 176 |
)
|
| 177 |
|
| 178 |
-
final_model_dir = os.path.join(os.getcwd(), "
|
| 179 |
os.makedirs(final_model_dir, exist_ok=True)
|
| 180 |
|
| 181 |
save_object(
|
|
@@ -187,7 +183,7 @@ class ModelTrainer:
|
|
| 187 |
preprocessor,
|
| 188 |
)
|
| 189 |
|
| 190 |
-
logging.info(f"Final model and preprocessor saved in
|
| 191 |
y_train_pred = best_model.predict(X_train)
|
| 192 |
y_test_pred = best_model.predict(X_test)
|
| 193 |
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
# ---------------- Dagshub + MLflow ----------------
|
| 45 |
+
dagshub.init(repo_owner="Inder-26",repo_name="NetworkSecurity",mlflow=True)
|
| 46 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
# ---------------- Helper: log visual artifacts ----------------
|
|
|
|
| 171 |
self.data_transformation_artifact.transformed_object_file_path
|
| 172 |
)
|
| 173 |
|
| 174 |
+
final_model_dir = os.path.join(os.getcwd(), "final_model")
|
| 175 |
os.makedirs(final_model_dir, exist_ok=True)
|
| 176 |
|
| 177 |
save_object(
|
|
|
|
| 183 |
preprocessor,
|
| 184 |
)
|
| 185 |
|
| 186 |
+
logging.info(f"Final model and preprocessor saved in final_model")
|
| 187 |
y_train_pred = best_model.predict(X_train)
|
| 188 |
y_test_pred = best_model.predict(X_test)
|
| 189 |
|
networksecurity/pipeline/training_pipeline.py
CHANGED
|
@@ -24,7 +24,7 @@ from networksecurity.entity.artifact_entity import (
|
|
| 24 |
ModelTrainerArtifact,
|
| 25 |
)
|
| 26 |
|
| 27 |
-
class
|
| 28 |
def __init__(self):
|
| 29 |
try:
|
| 30 |
self.training_pipeline_config = TrainingPipelineConfig()
|
|
@@ -111,7 +111,7 @@ class TraningPipeline:
|
|
| 111 |
raise NetworkSecurityException(e, sys)
|
| 112 |
|
| 113 |
|
| 114 |
-
## Local
|
| 115 |
def sync_saved_model_dir_to_s3(self):
|
| 116 |
try:
|
| 117 |
aws_bucket_url = (
|
|
|
|
| 24 |
ModelTrainerArtifact,
|
| 25 |
)
|
| 26 |
|
| 27 |
+
class TrainingPipeline:
|
| 28 |
def __init__(self):
|
| 29 |
try:
|
| 30 |
self.training_pipeline_config = TrainingPipelineConfig()
|
|
|
|
| 111 |
raise NetworkSecurityException(e, sys)
|
| 112 |
|
| 113 |
|
| 114 |
+
## Local final_model is pushed to S3
|
| 115 |
def sync_saved_model_dir_to_s3(self):
|
| 116 |
try:
|
| 117 |
aws_bucket_url = (
|
precision_recall_curve.png
DELETED
|
Binary file (14.8 kB)
|
|
|
prediction_output/output.csv
DELETED
|
@@ -1,13 +0,0 @@
|
|
| 1 |
-
having_IP_Address,URL_Length,Shortining_Service,having_At_Symbol,double_slash_redirecting,Prefix_Suffix,having_Sub_Domain,SSLfinal_State,Domain_registeration_length,Favicon,port,HTTPS_token,Request_URL,URL_of_Anchor,Links_in_tags,SFH,Submitting_to_email,Abnormal_URL,Redirect,on_mouseover,RightClick,popUpWidnow,Iframe,age_of_domain,DNSRecord,web_traffic,Page_Rank,Google_Index,Links_pointing_to_page,Statistical_report,prediction
|
| 2 |
-
1,-1,1,1,1,-1,1,1,1,1,1,-1,-1,1,1,0,1,1,0,1,1,1,1,1,1,-1,-1,1,1,1,1.0
|
| 3 |
-
-1,-1,-1,1,-1,1,1,1,-1,1,1,-1,1,1,0,1,1,-1,0,1,1,1,1,-1,-1,1,1,-1,1,1,1.0
|
| 4 |
-
-1,-1,-1,1,-1,-1,0,0,1,1,1,-1,-1,-1,1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,0,1,0.0
|
| 5 |
-
-1,-1,1,1,1,-1,1,1,1,1,1,1,-1,0,1,1,1,1,0,1,1,1,1,1,1,1,-1,1,1,1,1.0
|
| 6 |
-
1,1,1,1,1,-1,0,-1,-1,1,1,1,1,0,0,1,1,1,0,1,1,1,1,-1,1,1,-1,1,0,1,1.0
|
| 7 |
-
1,-1,1,1,1,1,0,-1,-1,1,1,1,1,0,0,-1,1,1,0,1,1,1,1,1,1,1,-1,1,0,1,1.0
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* ============================================
|
| 2 |
+
Design System & Variables
|
| 3 |
+
============================================ */
|
| 4 |
+
|
| 5 |
+
:root {
|
| 6 |
+
/* Colors */
|
| 7 |
+
--primary: #4f46e5; /* Indigo 600 */
|
| 8 |
+
--primary-dark: #4338ca;
|
| 9 |
+
--primary-light: #818cf8;
|
| 10 |
+
|
| 11 |
+
--secondary: #ec4899; /* Pink 500 */
|
| 12 |
+
|
| 13 |
+
--gray-50: #f9fafb;
|
| 14 |
+
--gray-100: #f3f4f6;
|
| 15 |
+
--gray-200: #e5e7eb;
|
| 16 |
+
--gray-300: #d1d5db;
|
| 17 |
+
--gray-400: #9ca3af;
|
| 18 |
+
--gray-500: #6b7280;
|
| 19 |
+
--gray-600: #4b5563;
|
| 20 |
+
--gray-700: #374151;
|
| 21 |
+
--gray-800: #1f2937;
|
| 22 |
+
--gray-900: #111827;
|
| 23 |
+
|
| 24 |
+
--white: #ffffff;
|
| 25 |
+
|
| 26 |
+
--success: #10b981; /* Emerald 500 */
|
| 27 |
+
--danger: #ef4444; /* Red 500 */
|
| 28 |
+
--warning: #f59e0b; /* Amber 500 */
|
| 29 |
+
--info: #3b82f6; /* Blue 500 */
|
| 30 |
+
|
| 31 |
+
/* Typography */
|
| 32 |
+
--font-sans: "Inter", system-ui, -apple-system, sans-serif;
|
| 33 |
+
|
| 34 |
+
/* Spacing & Layout */
|
| 35 |
+
--container-width: 1200px;
|
| 36 |
+
--header-height: 70px;
|
| 37 |
+
|
| 38 |
+
/* Effects */
|
| 39 |
+
--radius: 0.5rem;
|
| 40 |
+
--radius-lg: 1rem;
|
| 41 |
+
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
| 42 |
+
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
| 43 |
+
0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 44 |
+
--shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
| 45 |
+
0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
| 46 |
+
--shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
|
| 47 |
+
0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
| 48 |
+
|
| 49 |
+
--transition: all 0.3s ease;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/* ============================================
|
| 53 |
+
Reset & Base
|
| 54 |
+
============================================ */
|
| 55 |
+
|
| 56 |
+
* {
|
| 57 |
+
margin: 0;
|
| 58 |
+
padding: 0;
|
| 59 |
+
box-sizing: border-box;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
body {
|
| 63 |
+
font-family: var(--font-sans);
|
| 64 |
+
background-color: var(--gray-50);
|
| 65 |
+
color: var(--gray-800);
|
| 66 |
+
line-height: 1.6;
|
| 67 |
+
min-height: 100vh;
|
| 68 |
+
display: flex;
|
| 69 |
+
flex-direction: column;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
h1,
|
| 73 |
+
h2,
|
| 74 |
+
h3,
|
| 75 |
+
h4,
|
| 76 |
+
h5,
|
| 77 |
+
h6 {
|
| 78 |
+
line-height: 1.2;
|
| 79 |
+
color: var(--gray-900);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
a {
|
| 83 |
+
text-decoration: none;
|
| 84 |
+
color: inherit;
|
| 85 |
+
transition: var(--transition);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
ul {
|
| 89 |
+
list-style: none;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/* ============================================
|
| 93 |
+
Layout
|
| 94 |
+
============================================ */
|
| 95 |
+
|
| 96 |
+
.container {
|
| 97 |
+
max-width: var(--container-width);
|
| 98 |
+
margin: 0 auto;
|
| 99 |
+
padding: 0 1.5rem;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.main-content {
|
| 103 |
+
flex: 1;
|
| 104 |
+
padding: 3rem 0;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/* Header */
|
| 108 |
+
.header {
|
| 109 |
+
height: var(--header-height);
|
| 110 |
+
background: var(--white);
|
| 111 |
+
border-bottom: 1px solid var(--gray-200);
|
| 112 |
+
position: sticky;
|
| 113 |
+
top: 0;
|
| 114 |
+
z-index: 100;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
.header-content {
|
| 118 |
+
display: flex;
|
| 119 |
+
align-items: center;
|
| 120 |
+
justify-content: space-between;
|
| 121 |
+
height: 100%;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.logo {
|
| 125 |
+
display: flex;
|
| 126 |
+
align-items: center;
|
| 127 |
+
gap: 0.75rem;
|
| 128 |
+
font-size: 1.25rem;
|
| 129 |
+
font-weight: 700;
|
| 130 |
+
color: var(--primary);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
.logo i {
|
| 134 |
+
font-size: 1.5rem;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.nav-links {
|
| 138 |
+
display: flex;
|
| 139 |
+
gap: 2rem;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.nav-link {
|
| 143 |
+
display: flex;
|
| 144 |
+
align-items: center;
|
| 145 |
+
gap: 0.5rem;
|
| 146 |
+
color: var(--gray-600);
|
| 147 |
+
font-weight: 500;
|
| 148 |
+
font-size: 0.95rem;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.nav-link:hover {
|
| 152 |
+
color: var(--primary);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
/* Footer */
|
| 156 |
+
.footer {
|
| 157 |
+
background: var(--white);
|
| 158 |
+
border-top: 1px solid var(--gray-200);
|
| 159 |
+
padding: 2rem 0;
|
| 160 |
+
margin-top: auto;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
.footer-content {
|
| 164 |
+
display: flex;
|
| 165 |
+
justify-content: space-between;
|
| 166 |
+
align-items: center;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
.footer-logo {
|
| 170 |
+
display: flex;
|
| 171 |
+
align-items: center;
|
| 172 |
+
gap: 0.5rem;
|
| 173 |
+
font-weight: 600;
|
| 174 |
+
margin-bottom: 0.5rem;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.footer-left p {
|
| 178 |
+
color: var(--gray-500);
|
| 179 |
+
font-size: 0.9rem;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.footer-tech {
|
| 183 |
+
display: flex;
|
| 184 |
+
gap: 1rem;
|
| 185 |
+
margin-top: 0.5rem;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.footer-tech span {
|
| 189 |
+
display: flex;
|
| 190 |
+
align-items: center;
|
| 191 |
+
gap: 0.25rem;
|
| 192 |
+
font-size: 0.8rem;
|
| 193 |
+
color: var(--gray-500);
|
| 194 |
+
background: var(--gray-100);
|
| 195 |
+
padding: 0.1rem 0.5rem;
|
| 196 |
+
border-radius: 999px;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
.footer-right {
|
| 200 |
+
display: flex;
|
| 201 |
+
gap: 1.5rem;
|
| 202 |
+
font-size: 1.25rem;
|
| 203 |
+
color: var(--gray-400);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.footer-right a:hover {
|
| 207 |
+
color: var(--primary);
|
| 208 |
+
transform: translateY(-2px);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/* ============================================
|
| 212 |
+
Components
|
| 213 |
+
============================================ */
|
| 214 |
+
|
| 215 |
+
/* Buttons */
|
| 216 |
+
.btn {
|
| 217 |
+
display: inline-flex;
|
| 218 |
+
align-items: center;
|
| 219 |
+
justify-content: center;
|
| 220 |
+
gap: 0.5rem;
|
| 221 |
+
padding: 0.75rem 1.5rem;
|
| 222 |
+
border-radius: var(--radius);
|
| 223 |
+
font-weight: 600;
|
| 224 |
+
cursor: pointer;
|
| 225 |
+
border: none;
|
| 226 |
+
transition: var(--transition);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
.btn-sm {
|
| 230 |
+
padding: 0.4rem 0.8rem;
|
| 231 |
+
font-size: 0.875rem;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
.btn-lg {
|
| 235 |
+
padding: 1rem 2rem;
|
| 236 |
+
font-size: 1.125rem;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.btn-block {
|
| 240 |
+
width: 100%;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
.btn-primary {
|
| 244 |
+
background: var(--primary);
|
| 245 |
+
color: white;
|
| 246 |
+
box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.btn-primary:hover {
|
| 250 |
+
background: var(--primary-dark);
|
| 251 |
+
transform: translateY(-2px);
|
| 252 |
+
box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.5);
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.btn-outline {
|
| 256 |
+
background: transparent;
|
| 257 |
+
border: 2px solid var(--primary);
|
| 258 |
+
color: var(--primary);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.btn-outline:hover {
|
| 262 |
+
background: var(--gray-50);
|
| 263 |
+
transform: translateY(-1px);
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
.btn-secondary {
|
| 267 |
+
background: var(--secondary);
|
| 268 |
+
color: white;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
/* Cards */
|
| 272 |
+
.card {
|
| 273 |
+
background: var(--white);
|
| 274 |
+
border-radius: var(--radius-lg);
|
| 275 |
+
border: 1px solid var(--gray-200);
|
| 276 |
+
box-shadow: var(--shadow-sm);
|
| 277 |
+
transition: var(--transition);
|
| 278 |
+
height: 100%;
|
| 279 |
+
margin-bottom: 2rem;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
.card:hover {
|
| 283 |
+
box-shadow: var(--shadow-md);
|
| 284 |
+
transform: translateY(-2px);
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
.card-header {
|
| 288 |
+
padding: 1.5rem;
|
| 289 |
+
border-bottom: 1px solid var(--gray-100);
|
| 290 |
+
display: flex;
|
| 291 |
+
align-items: center;
|
| 292 |
+
justify-content: space-between;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
.card-header h2 {
|
| 296 |
+
font-size: 1.25rem;
|
| 297 |
+
font-weight: 600;
|
| 298 |
+
margin: 0;
|
| 299 |
+
display: flex;
|
| 300 |
+
align-items: center;
|
| 301 |
+
gap: 0.75rem;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.card-body {
|
| 305 |
+
padding: 1.5rem;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
/* Forms */
|
| 309 |
+
.form-group {
|
| 310 |
+
margin-bottom: 1.5rem;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
.form-label {
|
| 314 |
+
display: block;
|
| 315 |
+
font-weight: 600;
|
| 316 |
+
margin-bottom: 0.5rem;
|
| 317 |
+
color: var(--gray-700);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
.form-control {
|
| 321 |
+
width: 100%;
|
| 322 |
+
padding: 0.75rem;
|
| 323 |
+
border: 1px solid var(--gray-300);
|
| 324 |
+
border-radius: var(--radius);
|
| 325 |
+
transition: var(--transition);
|
| 326 |
+
font-family: inherit;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
.form-control:focus {
|
| 330 |
+
outline: none;
|
| 331 |
+
border-color: var(--primary);
|
| 332 |
+
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
/* ============================================
|
| 336 |
+
Page Specific: Home
|
| 337 |
+
============================================ */
|
| 338 |
+
|
| 339 |
+
/* Hero */
|
| 340 |
+
.hero {
|
| 341 |
+
background: radial-gradient(circle at top right, #e0e7ff, #f3f4f6);
|
| 342 |
+
padding: 5rem 0;
|
| 343 |
+
text-align: center;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
.hero-content {
|
| 347 |
+
max-width: 800px;
|
| 348 |
+
margin: 0 auto;
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
.hero-badge {
|
| 352 |
+
display: inline-flex;
|
| 353 |
+
align-items: center;
|
| 354 |
+
gap: 0.5rem;
|
| 355 |
+
background: white;
|
| 356 |
+
padding: 0.5rem 1rem;
|
| 357 |
+
border-radius: 9999px;
|
| 358 |
+
font-size: 0.875rem;
|
| 359 |
+
font-weight: 600;
|
| 360 |
+
color: var(--primary);
|
| 361 |
+
box-shadow: var(--shadow-sm);
|
| 362 |
+
margin-bottom: 1.5rem;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
.hero h1 {
|
| 366 |
+
font-size: 3.5rem;
|
| 367 |
+
font-weight: 800;
|
| 368 |
+
letter-spacing: -0.025em;
|
| 369 |
+
margin-bottom: 1.5rem;
|
| 370 |
+
background: linear-gradient(135deg, var(--gray-900) 50%, var(--primary));
|
| 371 |
+
-webkit-background-clip: text;
|
| 372 |
+
background-clip: text;
|
| 373 |
+
-webkit-text-fill-color: transparent;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
.hero-subtitle {
|
| 377 |
+
font-size: 1.25rem;
|
| 378 |
+
color: var(--gray-600);
|
| 379 |
+
margin-bottom: 3rem;
|
| 380 |
+
line-height: 1.6;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
.hero-stats {
|
| 384 |
+
display: grid;
|
| 385 |
+
grid-template-columns: repeat(4, 1fr);
|
| 386 |
+
gap: 1.5rem;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.stat-card {
|
| 390 |
+
background: white;
|
| 391 |
+
padding: 1.5rem;
|
| 392 |
+
border-radius: var(--radius-lg);
|
| 393 |
+
box-shadow: var(--shadow);
|
| 394 |
+
display: flex;
|
| 395 |
+
flex-direction: column;
|
| 396 |
+
align-items: center;
|
| 397 |
+
gap: 0.5rem;
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
.stat-icon {
|
| 401 |
+
font-size: 1.5rem;
|
| 402 |
+
color: var(--primary);
|
| 403 |
+
margin-bottom: 0.25rem;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
.stat-value {
|
| 407 |
+
font-size: 1.5rem;
|
| 408 |
+
font-weight: 700;
|
| 409 |
+
color: var(--gray-900);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
.stat-label {
|
| 413 |
+
font-size: 0.875rem;
|
| 414 |
+
color: var(--gray-500);
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
/* Upload Interface */
|
| 418 |
+
.upload-zone {
|
| 419 |
+
border: 2px dashed var(--gray-300);
|
| 420 |
+
border-radius: var(--radius-lg);
|
| 421 |
+
padding: 3rem 1.5rem;
|
| 422 |
+
background: var(--gray-50);
|
| 423 |
+
transition: var(--transition);
|
| 424 |
+
cursor: pointer;
|
| 425 |
+
position: relative;
|
| 426 |
+
margin-bottom: 1.5rem;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
.upload-zone:hover,
|
| 430 |
+
.upload-zone.dragover {
|
| 431 |
+
border-color: var(--primary);
|
| 432 |
+
background: #eef2ff;
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
.upload-content {
|
| 436 |
+
display: flex;
|
| 437 |
+
flex-direction: column;
|
| 438 |
+
align-items: center;
|
| 439 |
+
gap: 0.75rem;
|
| 440 |
+
color: var(--gray-500);
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
.upload-content i {
|
| 444 |
+
font-size: 3rem;
|
| 445 |
+
color: var(--gray-400);
|
| 446 |
+
margin-bottom: 0.5rem;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
.upload-content p {
|
| 450 |
+
font-weight: 600;
|
| 451 |
+
color: var(--gray-800);
|
| 452 |
+
margin: 0;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
#file-input {
|
| 456 |
+
position: absolute;
|
| 457 |
+
width: 100%;
|
| 458 |
+
height: 100%;
|
| 459 |
+
top: 0;
|
| 460 |
+
left: 0;
|
| 461 |
+
opacity: 0;
|
| 462 |
+
cursor: pointer;
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
.file-info {
|
| 466 |
+
display: none;
|
| 467 |
+
align-items: center;
|
| 468 |
+
padding: 1rem;
|
| 469 |
+
background: #eff6ff;
|
| 470 |
+
border: 1px solid #bfdbfe;
|
| 471 |
+
border-radius: var(--radius);
|
| 472 |
+
color: #1e40af;
|
| 473 |
+
margin-bottom: 1.5rem;
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
.file-info i {
|
| 477 |
+
font-size: 1.5rem;
|
| 478 |
+
margin-right: 0.75rem;
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
.btn-remove {
|
| 482 |
+
margin-left: auto;
|
| 483 |
+
background: none;
|
| 484 |
+
border: none;
|
| 485 |
+
color: #60a5fa;
|
| 486 |
+
cursor: pointer;
|
| 487 |
+
padding: 0.25rem;
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
.btn-remove:hover {
|
| 491 |
+
color: #1d4ed8;
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
/* Features List */
|
| 495 |
+
.features-grid {
|
| 496 |
+
display: grid;
|
| 497 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 498 |
+
gap: 2rem;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
.feature-group h4 {
|
| 502 |
+
display: flex;
|
| 503 |
+
align-items: center;
|
| 504 |
+
gap: 0.5rem;
|
| 505 |
+
font-size: 1rem;
|
| 506 |
+
margin-bottom: 1rem;
|
| 507 |
+
color: var(--gray-700);
|
| 508 |
+
padding-bottom: 0.5rem;
|
| 509 |
+
border-bottom: 1px solid var(--gray-200);
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
.feature-group ul {
|
| 513 |
+
display: flex;
|
| 514 |
+
flex-direction: column;
|
| 515 |
+
gap: 0.5rem;
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
.feature-group li {
|
| 519 |
+
font-size: 0.875rem;
|
| 520 |
+
color: var(--gray-600);
|
| 521 |
+
display: flex;
|
| 522 |
+
align-items: center;
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
.feature-group li::before {
|
| 526 |
+
content: "•";
|
| 527 |
+
color: var(--primary);
|
| 528 |
+
margin-right: 0.5rem;
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
.feature-group code {
|
| 532 |
+
background: var(--gray-100);
|
| 533 |
+
padding: 0.1rem 0.3rem;
|
| 534 |
+
border-radius: 4px;
|
| 535 |
+
font-size: 0.8em;
|
| 536 |
+
color: var(--gray-800);
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
.feature-note {
|
| 540 |
+
background: #fffbeb;
|
| 541 |
+
border: 1px solid #fde68a;
|
| 542 |
+
border-radius: var(--radius);
|
| 543 |
+
padding: 1rem;
|
| 544 |
+
margin-top: 2rem;
|
| 545 |
+
display: flex;
|
| 546 |
+
align-items: center;
|
| 547 |
+
gap: 0.75rem;
|
| 548 |
+
color: #92400e;
|
| 549 |
+
font-size: 0.9rem;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
/* ============================================
|
| 553 |
+
Rest of the file (Result Cards, Tables)
|
| 554 |
+
============================================ */
|
| 555 |
+
/* ... (Appending the previous file content here in the tool calling) ... */
|
| 556 |
+
|
| 557 |
+
/* [PREVIOUSLY EXISTING STYLES BELOW] */
|
| 558 |
+
|
| 559 |
+
/* ============================================
|
| 560 |
+
Manual Input Page
|
| 561 |
+
============================================ */
|
| 562 |
+
|
| 563 |
+
.manual-page .page-header {
|
| 564 |
+
text-align: center;
|
| 565 |
+
margin-bottom: 2rem;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
.manual-page .page-header h1 {
|
| 569 |
+
font-size: 2rem;
|
| 570 |
+
color: var(--gray-900);
|
| 571 |
+
margin-bottom: 0.5rem;
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
.manual-page .page-header p {
|
| 575 |
+
color: var(--gray-600);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
/* Result Card */
|
| 579 |
+
.result-card {
|
| 580 |
+
display: flex;
|
| 581 |
+
align-items: center;
|
| 582 |
+
gap: 1.5rem;
|
| 583 |
+
padding: 1.5rem 2rem;
|
| 584 |
+
border-radius: var(--radius-lg);
|
| 585 |
+
margin-bottom: 2rem;
|
| 586 |
+
animation: slideDown 0.3s ease;
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
.result-card.result-safe {
|
| 590 |
+
background: linear-gradient(135deg, #d1fae5, #a7f3d0);
|
| 591 |
+
border: 2px solid var(--success);
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
.result-card.result-danger {
|
| 595 |
+
background: linear-gradient(135deg, #fee2e2, #fecaca);
|
| 596 |
+
border: 2px solid var(--danger);
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
.result-icon {
|
| 600 |
+
font-size: 3rem;
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
.result-safe .result-icon {
|
| 604 |
+
color: var(--success);
|
| 605 |
+
}
|
| 606 |
+
.result-danger .result-icon {
|
| 607 |
+
color: var(--danger);
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
.result-content h2 {
|
| 611 |
+
font-size: 1.5rem;
|
| 612 |
+
margin-bottom: 0.25rem;
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
.result-action {
|
| 616 |
+
margin-left: auto;
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
/* Quick Actions */
|
| 620 |
+
.quick-actions {
|
| 621 |
+
display: flex;
|
| 622 |
+
gap: 0.75rem;
|
| 623 |
+
margin-bottom: 2rem;
|
| 624 |
+
flex-wrap: wrap;
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
/* Feature Groups */
|
| 628 |
+
.feature-groups {
|
| 629 |
+
display: flex;
|
| 630 |
+
flex-direction: column;
|
| 631 |
+
gap: 1.5rem;
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
.feature-group-card {
|
| 635 |
+
background: var(--white);
|
| 636 |
+
border-radius: var(--radius-lg);
|
| 637 |
+
box-shadow: var(--shadow-md);
|
| 638 |
+
overflow: hidden;
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
.group-header {
|
| 642 |
+
display: flex;
|
| 643 |
+
align-items: center;
|
| 644 |
+
gap: 0.75rem;
|
| 645 |
+
padding: 1rem 1.5rem;
|
| 646 |
+
background: var(--gray-50);
|
| 647 |
+
border-bottom: 1px solid var(--gray-200);
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
.group-header i {
|
| 651 |
+
color: var(--primary);
|
| 652 |
+
font-size: 1.25rem;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
.group-header h3 {
|
| 656 |
+
font-size: 1rem;
|
| 657 |
+
font-weight: 600;
|
| 658 |
+
color: var(--gray-800);
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
.inputs-grid {
|
| 662 |
+
display: grid;
|
| 663 |
+
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
| 664 |
+
gap: 1rem;
|
| 665 |
+
padding: 1.5rem;
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
.input-item {
|
| 669 |
+
display: flex;
|
| 670 |
+
flex-direction: column;
|
| 671 |
+
gap: 0.5rem;
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
.input-item label {
|
| 675 |
+
font-size: 0.8rem;
|
| 676 |
+
font-weight: 600;
|
| 677 |
+
color: var(--gray-700);
|
| 678 |
+
font-family: monospace;
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
/* Radio Button Group */
|
| 682 |
+
.radio-group {
|
| 683 |
+
display: flex;
|
| 684 |
+
gap: 0.5rem;
|
| 685 |
+
}
|
| 686 |
+
|
| 687 |
+
.radio-label {
|
| 688 |
+
flex: 1;
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
.radio-label input {
|
| 692 |
+
display: none;
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
.radio-btn {
|
| 696 |
+
display: block;
|
| 697 |
+
padding: 0.5rem;
|
| 698 |
+
text-align: center;
|
| 699 |
+
border-radius: var(--radius);
|
| 700 |
+
font-weight: 600;
|
| 701 |
+
font-size: 0.875rem;
|
| 702 |
+
cursor: pointer;
|
| 703 |
+
transition: var(--transition);
|
| 704 |
+
border: 2px solid transparent;
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
.radio-btn.danger {
|
| 708 |
+
background: #fef2f2;
|
| 709 |
+
color: var(--danger);
|
| 710 |
+
border-color: #fecaca;
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
.radio-btn.warning {
|
| 714 |
+
background: #fffbeb;
|
| 715 |
+
color: var(--warning);
|
| 716 |
+
border-color: #fde68a;
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
.radio-btn.success {
|
| 720 |
+
background: #f0fdf4;
|
| 721 |
+
color: var(--success);
|
| 722 |
+
border-color: #bbf7d0;
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
.radio-label input:checked + .radio-btn.danger {
|
| 726 |
+
background: var(--danger);
|
| 727 |
+
color: white;
|
| 728 |
+
border-color: var(--danger);
|
| 729 |
+
}
|
| 730 |
+
|
| 731 |
+
.radio-label input:checked + .radio-btn.warning {
|
| 732 |
+
background: var(--warning);
|
| 733 |
+
color: white;
|
| 734 |
+
border-color: var(--warning);
|
| 735 |
+
}
|
| 736 |
+
|
| 737 |
+
.radio-label input:checked + .radio-btn.success {
|
| 738 |
+
background: var(--success);
|
| 739 |
+
color: white;
|
| 740 |
+
border-color: var(--success);
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
/* Form Actions */
|
| 744 |
+
.form-actions {
|
| 745 |
+
text-align: center;
|
| 746 |
+
margin-top: 2rem;
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
/* Legend */
|
| 750 |
+
.legend-card {
|
| 751 |
+
background: var(--gray-100);
|
| 752 |
+
border-radius: var(--radius-lg);
|
| 753 |
+
padding: 1.5rem;
|
| 754 |
+
margin-top: 2rem;
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
.legend-card h4 {
|
| 758 |
+
display: flex;
|
| 759 |
+
align-items: center;
|
| 760 |
+
gap: 0.5rem;
|
| 761 |
+
margin-bottom: 1rem;
|
| 762 |
+
color: var(--gray-700);
|
| 763 |
+
}
|
| 764 |
+
|
| 765 |
+
.legend-items {
|
| 766 |
+
display: flex;
|
| 767 |
+
gap: 2rem;
|
| 768 |
+
flex-wrap: wrap;
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
.legend-item {
|
| 772 |
+
display: flex;
|
| 773 |
+
align-items: center;
|
| 774 |
+
gap: 0.75rem;
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
.legend-badge {
|
| 778 |
+
padding: 0.25rem 0.75rem;
|
| 779 |
+
border-radius: var(--radius);
|
| 780 |
+
font-weight: 600;
|
| 781 |
+
font-size: 0.875rem;
|
| 782 |
+
}
|
| 783 |
+
|
| 784 |
+
.legend-badge.danger {
|
| 785 |
+
background: var(--danger);
|
| 786 |
+
color: white;
|
| 787 |
+
}
|
| 788 |
+
.legend-badge.warning {
|
| 789 |
+
background: var(--warning);
|
| 790 |
+
color: white;
|
| 791 |
+
}
|
| 792 |
+
.legend-badge.success {
|
| 793 |
+
background: var(--success);
|
| 794 |
+
color: white;
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
/* ============================================
|
| 798 |
+
Model Comparison Table
|
| 799 |
+
============================================ */
|
| 800 |
+
|
| 801 |
+
.models-table-container {
|
| 802 |
+
overflow-x: auto;
|
| 803 |
+
}
|
| 804 |
+
|
| 805 |
+
.models-table {
|
| 806 |
+
width: 100%;
|
| 807 |
+
border-collapse: collapse;
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
.models-table th,
|
| 811 |
+
.models-table td {
|
| 812 |
+
padding: 1rem;
|
| 813 |
+
text-align: left;
|
| 814 |
+
border-bottom: 1px solid var(--gray-200);
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
.models-table th {
|
| 818 |
+
background: var(--gray-50);
|
| 819 |
+
font-weight: 600;
|
| 820 |
+
font-size: 0.75rem;
|
| 821 |
+
text-transform: uppercase;
|
| 822 |
+
letter-spacing: 0.05em;
|
| 823 |
+
color: var(--gray-600);
|
| 824 |
+
}
|
| 825 |
+
|
| 826 |
+
.models-table tr.best-model {
|
| 827 |
+
background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), transparent);
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
+
.model-name {
|
| 831 |
+
display: flex;
|
| 832 |
+
align-items: center;
|
| 833 |
+
gap: 0.5rem;
|
| 834 |
+
font-weight: 600;
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
.trophy-icon {
|
| 838 |
+
color: #fbbf24;
|
| 839 |
+
}
|
| 840 |
+
|
| 841 |
+
.metric-bar {
|
| 842 |
+
position: relative;
|
| 843 |
+
height: 24px;
|
| 844 |
+
background: var(--gray-100);
|
| 845 |
+
border-radius: var(--radius);
|
| 846 |
+
overflow: hidden;
|
| 847 |
+
min-width: 100px;
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
.metric-fill {
|
| 851 |
+
position: absolute;
|
| 852 |
+
left: 0;
|
| 853 |
+
top: 0;
|
| 854 |
+
height: 100%;
|
| 855 |
+
background: var(--primary);
|
| 856 |
+
opacity: 0.2;
|
| 857 |
+
transition: width 0.5s ease;
|
| 858 |
+
}
|
| 859 |
+
|
| 860 |
+
.metric-fill.f1 {
|
| 861 |
+
background: var(--success);
|
| 862 |
+
}
|
| 863 |
+
.metric-fill.precision {
|
| 864 |
+
background: var(--info);
|
| 865 |
+
}
|
| 866 |
+
.metric-fill.recall {
|
| 867 |
+
background: var(--secondary);
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
.metric-bar span {
|
| 871 |
+
position: relative;
|
| 872 |
+
z-index: 1;
|
| 873 |
+
display: flex;
|
| 874 |
+
align-items: center;
|
| 875 |
+
height: 100%;
|
| 876 |
+
padding: 0 0.75rem;
|
| 877 |
+
font-weight: 600;
|
| 878 |
+
font-size: 0.8rem;
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
.badge {
|
| 882 |
+
display: inline-flex;
|
| 883 |
+
align-items: center;
|
| 884 |
+
gap: 0.25rem;
|
| 885 |
+
padding: 0.25rem 0.75rem;
|
| 886 |
+
border-radius: 9999px;
|
| 887 |
+
font-size: 0.75rem;
|
| 888 |
+
font-weight: 600;
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
+
.badge-success {
|
| 892 |
+
background: rgba(16, 185, 129, 0.1);
|
| 893 |
+
color: var(--success);
|
| 894 |
+
}
|
| 895 |
+
|
| 896 |
+
.badge-secondary {
|
| 897 |
+
background: var(--gray-100);
|
| 898 |
+
color: var(--gray-600);
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
/* ============================================
|
| 902 |
+
Pipeline Steps
|
| 903 |
+
============================================ */
|
| 904 |
+
|
| 905 |
+
.pipeline-steps {
|
| 906 |
+
display: flex;
|
| 907 |
+
align-items: flex-start;
|
| 908 |
+
justify-content: space-between;
|
| 909 |
+
gap: 0.5rem;
|
| 910 |
+
flex-wrap: wrap;
|
| 911 |
+
}
|
| 912 |
+
|
| 913 |
+
.pipeline-step {
|
| 914 |
+
flex: 1;
|
| 915 |
+
min-width: 140px;
|
| 916 |
+
text-align: center;
|
| 917 |
+
padding: 1rem;
|
| 918 |
+
position: relative;
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
.step-number {
|
| 922 |
+
position: absolute;
|
| 923 |
+
top: 0;
|
| 924 |
+
right: 1rem;
|
| 925 |
+
width: 24px;
|
| 926 |
+
height: 24px;
|
| 927 |
+
background: var(--primary);
|
| 928 |
+
color: white;
|
| 929 |
+
border-radius: 50%;
|
| 930 |
+
display: flex;
|
| 931 |
+
align-items: center;
|
| 932 |
+
justify-content: center;
|
| 933 |
+
font-size: 0.75rem;
|
| 934 |
+
font-weight: 700;
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
.step-icon {
|
| 938 |
+
width: 60px;
|
| 939 |
+
height: 60px;
|
| 940 |
+
margin: 0 auto 1rem;
|
| 941 |
+
background: linear-gradient(135deg, var(--primary), var(--secondary));
|
| 942 |
+
border-radius: var(--radius-lg);
|
| 943 |
+
display: flex;
|
| 944 |
+
align-items: center;
|
| 945 |
+
justify-content: center;
|
| 946 |
+
color: white;
|
| 947 |
+
font-size: 1.5rem;
|
| 948 |
+
}
|
| 949 |
+
|
| 950 |
+
.pipeline-step h4 {
|
| 951 |
+
font-size: 0.9rem;
|
| 952 |
+
margin-bottom: 0.5rem;
|
| 953 |
+
color: var(--gray-800);
|
| 954 |
+
}
|
| 955 |
+
|
| 956 |
+
.pipeline-step p {
|
| 957 |
+
font-size: 0.75rem;
|
| 958 |
+
color: var(--gray-500);
|
| 959 |
+
}
|
| 960 |
+
|
| 961 |
+
.pipeline-arrow {
|
| 962 |
+
display: flex;
|
| 963 |
+
align-items: center;
|
| 964 |
+
color: var(--gray-300);
|
| 965 |
+
font-size: 1.5rem;
|
| 966 |
+
padding-top: 2rem;
|
| 967 |
+
}
|
| 968 |
+
|
| 969 |
+
@media (max-width: 768px) {
|
| 970 |
+
.pipeline-arrow {
|
| 971 |
+
display: none;
|
| 972 |
+
}
|
| 973 |
+
|
| 974 |
+
.pipeline-steps {
|
| 975 |
+
flex-direction: column;
|
| 976 |
+
}
|
| 977 |
+
|
| 978 |
+
.pipeline-step {
|
| 979 |
+
width: 100%;
|
| 980 |
+
}
|
| 981 |
+
}
|
| 982 |
+
|
| 983 |
+
/* ============================================
|
| 984 |
+
Prediction Options
|
| 985 |
+
============================================ */
|
| 986 |
+
|
| 987 |
+
.prediction-options {
|
| 988 |
+
margin-bottom: 3rem;
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
.section-title {
|
| 992 |
+
display: flex;
|
| 993 |
+
align-items: center;
|
| 994 |
+
gap: 0.75rem;
|
| 995 |
+
font-size: 1.25rem;
|
| 996 |
+
margin-bottom: 1.5rem;
|
| 997 |
+
color: var(--gray-800);
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
.section-title i {
|
| 1001 |
+
color: var(--primary);
|
| 1002 |
+
}
|
| 1003 |
+
|
| 1004 |
+
.options-grid {
|
| 1005 |
+
display: grid;
|
| 1006 |
+
grid-template-columns: repeat(2, 1fr);
|
| 1007 |
+
gap: 2rem;
|
| 1008 |
+
}
|
| 1009 |
+
|
| 1010 |
+
@media (max-width: 768px) {
|
| 1011 |
+
.options-grid {
|
| 1012 |
+
grid-template-columns: 1fr;
|
| 1013 |
+
}
|
| 1014 |
+
}
|
| 1015 |
+
|
| 1016 |
+
.upload-card,
|
| 1017 |
+
.manual-card,
|
| 1018 |
+
.train-card {
|
| 1019 |
+
padding: 2rem;
|
| 1020 |
+
text-align: center;
|
| 1021 |
+
}
|
| 1022 |
+
|
| 1023 |
+
.train-card {
|
| 1024 |
+
grid-column: 1 / -1;
|
| 1025 |
+
}
|
| 1026 |
+
|
| 1027 |
+
.card-icon {
|
| 1028 |
+
width: 80px;
|
| 1029 |
+
height: 80px;
|
| 1030 |
+
margin: 0 auto 1.5rem;
|
| 1031 |
+
background: linear-gradient(135deg, var(--primary), var(--secondary));
|
| 1032 |
+
border-radius: 50%;
|
| 1033 |
+
display: flex;
|
| 1034 |
+
align-items: center;
|
| 1035 |
+
justify-content: center;
|
| 1036 |
+
color: white;
|
| 1037 |
+
font-size: 2rem;
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
.upload-card,
|
| 1041 |
+
.manual-card,
|
| 1042 |
+
.train-card {
|
| 1043 |
+
padding: 2rem;
|
| 1044 |
+
text-align: center;
|
| 1045 |
+
}
|
| 1046 |
+
|
| 1047 |
+
.upload-card h3,
|
| 1048 |
+
.manual-card h3,
|
| 1049 |
+
.train-card h3 {
|
| 1050 |
+
font-size: 1.25rem;
|
| 1051 |
+
margin-bottom: 0.5rem;
|
| 1052 |
+
color: var(--gray-800);
|
| 1053 |
+
}
|
| 1054 |
+
|
| 1055 |
+
.upload-card p,
|
| 1056 |
+
.manual-card p,
|
| 1057 |
+
.train-card p {
|
| 1058 |
+
color: var(--gray-500);
|
| 1059 |
+
margin-bottom: 1.5rem;
|
| 1060 |
+
}
|
| 1061 |
+
|
| 1062 |
+
.manual-preview {
|
| 1063 |
+
background: var(--gray-50);
|
| 1064 |
+
border-radius: var(--radius);
|
| 1065 |
+
padding: 1rem;
|
| 1066 |
+
margin-bottom: 1.5rem;
|
| 1067 |
+
text-align: left;
|
| 1068 |
+
}
|
| 1069 |
+
|
| 1070 |
+
.feature-preview {
|
| 1071 |
+
display: flex;
|
| 1072 |
+
justify-content: space-between;
|
| 1073 |
+
padding: 0.5rem 0;
|
| 1074 |
+
border-bottom: 1px solid var(--gray-200);
|
| 1075 |
+
}
|
| 1076 |
+
|
| 1077 |
+
.feature-name {
|
| 1078 |
+
font-family: monospace;
|
| 1079 |
+
font-size: 0.8rem;
|
| 1080 |
+
color: var(--gray-700);
|
| 1081 |
+
}
|
| 1082 |
+
|
| 1083 |
+
.feature-values {
|
| 1084 |
+
font-size: 0.75rem;
|
| 1085 |
+
color: var(--gray-500);
|
| 1086 |
+
}
|
| 1087 |
+
|
| 1088 |
+
.more-features {
|
| 1089 |
+
text-align: center;
|
| 1090 |
+
padding-top: 0.75rem;
|
| 1091 |
+
color: var(--primary);
|
| 1092 |
+
font-size: 0.875rem;
|
| 1093 |
+
font-weight: 500;
|
| 1094 |
+
}
|
| 1095 |
+
|
| 1096 |
+
.btn-secondary {
|
| 1097 |
+
background: var(--secondary);
|
| 1098 |
+
color: white;
|
| 1099 |
+
}
|
| 1100 |
+
|
| 1101 |
+
.btn-secondary:hover {
|
| 1102 |
+
background: #7c3aed;
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
/* ============================================
|
| 1106 |
+
Animations
|
| 1107 |
+
============================================ */
|
| 1108 |
+
|
| 1109 |
+
@keyframes slideDown {
|
| 1110 |
+
from {
|
| 1111 |
+
opacity: 0;
|
| 1112 |
+
transform: translateY(-20px);
|
| 1113 |
+
}
|
| 1114 |
+
to {
|
| 1115 |
+
opacity: 1;
|
| 1116 |
+
transform: translateY(0);
|
| 1117 |
+
}
|
| 1118 |
+
}
|
| 1119 |
+
|
| 1120 |
+
/* ============================================
|
| 1121 |
+
Notifications
|
| 1122 |
+
============================================ */
|
| 1123 |
+
.notification {
|
| 1124 |
+
position: fixed;
|
| 1125 |
+
top: 20px;
|
| 1126 |
+
right: 20px;
|
| 1127 |
+
background: white;
|
| 1128 |
+
padding: 1rem 1.5rem;
|
| 1129 |
+
border-radius: var(--radius);
|
| 1130 |
+
box-shadow: var(--shadow-lg);
|
| 1131 |
+
display: flex;
|
| 1132 |
+
align-items: center;
|
| 1133 |
+
gap: 0.75rem;
|
| 1134 |
+
z-index: 1000;
|
| 1135 |
+
transform: translateX(120%);
|
| 1136 |
+
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 1137 |
+
border-left: 4px solid var(--info);
|
| 1138 |
+
max-width: 400px;
|
| 1139 |
+
}
|
| 1140 |
+
|
| 1141 |
+
.notification.show {
|
| 1142 |
+
transform: translateX(0);
|
| 1143 |
+
}
|
| 1144 |
+
|
| 1145 |
+
.notification-success {
|
| 1146 |
+
border-left-color: var(--success);
|
| 1147 |
+
}
|
| 1148 |
+
.notification-success i {
|
| 1149 |
+
color: var(--success);
|
| 1150 |
+
}
|
| 1151 |
+
|
| 1152 |
+
.notification-error {
|
| 1153 |
+
border-left-color: var(--danger);
|
| 1154 |
+
}
|
| 1155 |
+
.notification-error i {
|
| 1156 |
+
color: var(--danger);
|
| 1157 |
+
}
|
| 1158 |
+
|
| 1159 |
+
.notification-info {
|
| 1160 |
+
border-left-color: var(--info);
|
| 1161 |
+
}
|
| 1162 |
+
.notification-info i {
|
| 1163 |
+
color: var(--info);
|
| 1164 |
+
}
|
| 1165 |
+
|
| 1166 |
+
/* ============================================
|
| 1167 |
+
Modal
|
| 1168 |
+
============================================ */
|
| 1169 |
+
.modal-overlay {
|
| 1170 |
+
position: fixed;
|
| 1171 |
+
top: 0;
|
| 1172 |
+
left: 0;
|
| 1173 |
+
width: 100%;
|
| 1174 |
+
height: 100%;
|
| 1175 |
+
background: rgba(0, 0, 0, 0.5);
|
| 1176 |
+
backdrop-filter: blur(4px);
|
| 1177 |
+
display: flex;
|
| 1178 |
+
justify-content: center;
|
| 1179 |
+
align-items: center;
|
| 1180 |
+
z-index: 2000;
|
| 1181 |
+
opacity: 0;
|
| 1182 |
+
visibility: hidden;
|
| 1183 |
+
transition: all 0.3s ease;
|
| 1184 |
+
}
|
| 1185 |
+
|
| 1186 |
+
.modal-overlay.show {
|
| 1187 |
+
opacity: 1;
|
| 1188 |
+
visibility: visible;
|
| 1189 |
+
}
|
| 1190 |
+
|
| 1191 |
+
.modal-content {
|
| 1192 |
+
background: white;
|
| 1193 |
+
padding: 2.5rem;
|
| 1194 |
+
border-radius: var(--radius-lg);
|
| 1195 |
+
box-shadow: var(--shadow-lg);
|
| 1196 |
+
max-width: 500px;
|
| 1197 |
+
width: 90%;
|
| 1198 |
+
text-align: center;
|
| 1199 |
+
position: relative;
|
| 1200 |
+
transform: scale(0.9);
|
| 1201 |
+
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
| 1202 |
+
}
|
| 1203 |
+
|
| 1204 |
+
.modal-overlay.show .modal-content {
|
| 1205 |
+
transform: scale(1);
|
| 1206 |
+
}
|
| 1207 |
+
|
| 1208 |
+
.close-modal {
|
| 1209 |
+
position: absolute;
|
| 1210 |
+
top: 1rem;
|
| 1211 |
+
right: 1rem;
|
| 1212 |
+
background: none;
|
| 1213 |
+
border: none;
|
| 1214 |
+
font-size: 1.5rem;
|
| 1215 |
+
color: var(--gray-400);
|
| 1216 |
+
cursor: pointer;
|
| 1217 |
+
transition: var(--transition);
|
| 1218 |
+
}
|
| 1219 |
+
|
| 1220 |
+
.close-modal:hover {
|
| 1221 |
+
color: var(--danger);
|
| 1222 |
+
transform: rotate(90deg);
|
| 1223 |
+
}
|
| 1224 |
+
|
| 1225 |
+
.modal-icon {
|
| 1226 |
+
font-size: 4rem;
|
| 1227 |
+
margin-bottom: 1.5rem;
|
| 1228 |
+
color: var(--success);
|
| 1229 |
+
}
|
| 1230 |
+
|
| 1231 |
+
.modal-title {
|
| 1232 |
+
font-size: 1.5rem;
|
| 1233 |
+
font-weight: 700;
|
| 1234 |
+
color: var(--gray-900);
|
| 1235 |
+
margin-bottom: 1rem;
|
| 1236 |
+
}
|
| 1237 |
+
|
| 1238 |
+
.modal-message {
|
| 1239 |
+
color: var(--gray-600);
|
| 1240 |
+
line-height: 1.6;
|
| 1241 |
+
margin-bottom: 2rem;
|
| 1242 |
+
}
|
| 1243 |
+
|
| 1244 |
+
.modal-actions {
|
| 1245 |
+
display: flex;
|
| 1246 |
+
justify-content: center;
|
| 1247 |
+
gap: 1rem;
|
| 1248 |
+
}
|
| 1249 |
+
|
| 1250 |
+
/* ============================================
|
| 1251 |
+
Results Page
|
| 1252 |
+
============================================ */
|
| 1253 |
+
.results-header {
|
| 1254 |
+
display: flex;
|
| 1255 |
+
justify-content: space-between;
|
| 1256 |
+
align-items: center;
|
| 1257 |
+
margin-bottom: 2rem;
|
| 1258 |
+
flex-wrap: wrap;
|
| 1259 |
+
gap: 1rem;
|
| 1260 |
+
}
|
| 1261 |
+
|
| 1262 |
+
.results-title h1 {
|
| 1263 |
+
font-size: 2rem;
|
| 1264 |
+
margin-bottom: 0.5rem;
|
| 1265 |
+
display: flex;
|
| 1266 |
+
align-items: center;
|
| 1267 |
+
gap: 0.75rem;
|
| 1268 |
+
}
|
| 1269 |
+
|
| 1270 |
+
.results-title h1 i {
|
| 1271 |
+
color: var(--primary);
|
| 1272 |
+
}
|
| 1273 |
+
|
| 1274 |
+
.summary-grid {
|
| 1275 |
+
display: grid;
|
| 1276 |
+
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
| 1277 |
+
gap: 1.5rem;
|
| 1278 |
+
margin-bottom: 2rem;
|
| 1279 |
+
}
|
| 1280 |
+
|
| 1281 |
+
.summary-card {
|
| 1282 |
+
background: white;
|
| 1283 |
+
padding: 1.5rem;
|
| 1284 |
+
border-radius: var(--radius);
|
| 1285 |
+
box-shadow: var(--shadow-sm);
|
| 1286 |
+
display: flex;
|
| 1287 |
+
align-items: center;
|
| 1288 |
+
gap: 1.5rem;
|
| 1289 |
+
position: relative;
|
| 1290 |
+
overflow: hidden;
|
| 1291 |
+
transition: var(--transition);
|
| 1292 |
+
}
|
| 1293 |
+
|
| 1294 |
+
.summary-card:hover {
|
| 1295 |
+
transform: translateY(-5px);
|
| 1296 |
+
box-shadow: var(--shadow-md);
|
| 1297 |
+
}
|
| 1298 |
+
|
| 1299 |
+
.summary-icon {
|
| 1300 |
+
width: 60px;
|
| 1301 |
+
height: 60px;
|
| 1302 |
+
border-radius: 50%;
|
| 1303 |
+
display: flex;
|
| 1304 |
+
align-items: center;
|
| 1305 |
+
justify-content: center;
|
| 1306 |
+
font-size: 1.5rem;
|
| 1307 |
+
flex-shrink: 0;
|
| 1308 |
+
}
|
| 1309 |
+
|
| 1310 |
+
.summary-card.total .summary-icon { background: var(--gray-100); color: var(--gray-600); }
|
| 1311 |
+
.summary-card.safe .summary-icon { background: #dcfce7; color: var(--success); }
|
| 1312 |
+
.summary-card.danger .summary-icon { background: #fee2e2; color: var(--danger); }
|
| 1313 |
+
.summary-card.threat .summary-icon { background: #e0e7ff; color: var(--primary); }
|
| 1314 |
+
|
| 1315 |
+
.summary-info {
|
| 1316 |
+
display: flex;
|
| 1317 |
+
flex-direction: column;
|
| 1318 |
+
}
|
| 1319 |
+
|
| 1320 |
+
.summary-value {
|
| 1321 |
+
font-size: 1.75rem;
|
| 1322 |
+
font-weight: 700;
|
| 1323 |
+
color: var(--gray-900);
|
| 1324 |
+
line-height: 1.2;
|
| 1325 |
+
}
|
| 1326 |
+
|
| 1327 |
+
.summary-label {
|
| 1328 |
+
font-size: 0.875rem;
|
| 1329 |
+
color: var(--gray-500);
|
| 1330 |
+
}
|
| 1331 |
+
|
| 1332 |
+
.summary-percent {
|
| 1333 |
+
position: absolute;
|
| 1334 |
+
top: 1rem;
|
| 1335 |
+
right: 1rem;
|
| 1336 |
+
font-size: 0.875rem;
|
| 1337 |
+
font-weight: 600;
|
| 1338 |
+
opacity: 0.8;
|
| 1339 |
+
}
|
| 1340 |
+
|
| 1341 |
+
.summary-card.safe .summary-percent { color: var(--success); }
|
| 1342 |
+
.summary-card.danger .summary-percent { color: var(--danger); }
|
| 1343 |
+
|
| 1344 |
+
/* Threat Visualization */
|
| 1345 |
+
.threat-visual {
|
| 1346 |
+
padding: 1rem 0;
|
| 1347 |
+
}
|
| 1348 |
+
|
| 1349 |
+
.threat-bar-container {
|
| 1350 |
+
height: 24px;
|
| 1351 |
+
background: var(--gray-100);
|
| 1352 |
+
border-radius: 12px;
|
| 1353 |
+
overflow: hidden;
|
| 1354 |
+
margin-bottom: 1.5rem;
|
| 1355 |
+
}
|
| 1356 |
+
|
| 1357 |
+
.threat-bar {
|
| 1358 |
+
display: flex;
|
| 1359 |
+
height: 100%;
|
| 1360 |
+
}
|
| 1361 |
+
|
| 1362 |
+
.threat-segment {
|
| 1363 |
+
display: flex;
|
| 1364 |
+
align-items: center;
|
| 1365 |
+
justify-content: center;
|
| 1366 |
+
color: white;
|
| 1367 |
+
font-size: 0.75rem;
|
| 1368 |
+
font-weight: 600;
|
| 1369 |
+
transition: width 1s ease-out;
|
| 1370 |
+
}
|
| 1371 |
+
|
| 1372 |
+
.threat-segment.safe { background: var(--success); }
|
| 1373 |
+
.threat-segment.danger { background: var(--danger); }
|
| 1374 |
+
|
| 1375 |
+
.threat-message {
|
| 1376 |
+
background: var(--gray-50);
|
| 1377 |
+
padding: 1rem;
|
| 1378 |
+
border-radius: var(--radius);
|
| 1379 |
+
}
|
| 1380 |
+
|
| 1381 |
+
.threat-message i {
|
| 1382 |
+
|
| 1383 |
+
font-size: 1.25rem;
|
| 1384 |
+
margin-right: 0.75rem;
|
| 1385 |
+
vertical-align: middle;
|
| 1386 |
+
}
|
| 1387 |
+
|
| 1388 |
+
.message-safe i { color: var(--success); }
|
| 1389 |
+
.message-warning i { color: var(--warning); }
|
| 1390 |
+
.message-danger i { color: var(--danger); }
|
| 1391 |
+
|
| 1392 |
+
/* Results Table */
|
| 1393 |
+
.table-wrapper {
|
| 1394 |
+
overflow-x: auto;
|
| 1395 |
+
}
|
| 1396 |
+
|
| 1397 |
+
.results-table {
|
| 1398 |
+
width: 100%;
|
| 1399 |
+
border-collapse: collapse;
|
| 1400 |
+
}
|
| 1401 |
+
|
| 1402 |
+
.results-table th,
|
| 1403 |
+
.results-table td {
|
| 1404 |
+
padding: 1rem;
|
| 1405 |
+
text-align: left;
|
| 1406 |
+
border-bottom: 1px solid var(--gray-200);
|
| 1407 |
+
}
|
| 1408 |
+
|
| 1409 |
+
.results-table th {
|
| 1410 |
+
background: var(--gray-50);
|
| 1411 |
+
font-weight: 600;
|
| 1412 |
+
color: var(--gray-700);
|
| 1413 |
+
white-space: nowrap;
|
| 1414 |
+
}
|
| 1415 |
+
|
| 1416 |
+
.results-table tr:hover {
|
| 1417 |
+
background: var(--gray-50);
|
| 1418 |
+
}
|
| 1419 |
+
|
| 1420 |
+
.results-table .col-index {
|
| 1421 |
+
width: 60px;
|
| 1422 |
+
color: var(--gray-400);
|
| 1423 |
+
}
|
| 1424 |
+
|
| 1425 |
+
.label-badge {
|
| 1426 |
+
display: inline-block;
|
| 1427 |
+
padding: 0.25rem 0.75rem;
|
| 1428 |
+
border-radius: 20px;
|
| 1429 |
+
font-size: 0.75rem;
|
| 1430 |
+
font-weight: 600;
|
| 1431 |
+
}
|
| 1432 |
+
|
| 1433 |
+
.label-badge.success { background: #dcfce7; color: var(--success); }
|
| 1434 |
+
.label-badge.danger { background: #fee2e2; color: var(--danger); }
|
| 1435 |
+
|
| 1436 |
+
.confidence-bar {
|
| 1437 |
+
display: flex;
|
| 1438 |
+
align-items: center;
|
| 1439 |
+
gap: 0.5rem;
|
| 1440 |
+
width: 120px;
|
| 1441 |
+
}
|
| 1442 |
+
|
| 1443 |
+
.confidence-fill {
|
| 1444 |
+
height: 6px;
|
| 1445 |
+
border-radius: 3px;
|
| 1446 |
+
background: var(--primary);
|
| 1447 |
+
flex-grow: 1;
|
| 1448 |
+
}
|
| 1449 |
+
|
| 1450 |
+
.bottom-actions {
|
| 1451 |
+
display: flex;
|
| 1452 |
+
justify-content: center;
|
| 1453 |
+
gap: 1.5rem;
|
| 1454 |
+
margin-top: 3rem;
|
| 1455 |
+
flex-wrap: wrap;
|
| 1456 |
+
}
|
static/js/main.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ============================================
|
| 2 |
+
// Network Security - Main JavaScript
|
| 3 |
+
// ============================================
|
| 4 |
+
|
| 5 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 6 |
+
initFileUpload();
|
| 7 |
+
initTrainingHandler();
|
| 8 |
+
initAnimations();
|
| 9 |
+
initDynamicWidths();
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
// ============================================
|
| 13 |
+
// Training Handler
|
| 14 |
+
// ============================================
|
| 15 |
+
|
| 16 |
+
function initTrainingHandler() {
|
| 17 |
+
const trainBtn = document.getElementById('train-btn');
|
| 18 |
+
if (!trainBtn) return;
|
| 19 |
+
|
| 20 |
+
// Create Modal HTML if not exists
|
| 21 |
+
if (!document.getElementById('success-modal')) {
|
| 22 |
+
const modalHtml = `
|
| 23 |
+
<div id="success-modal" class="modal-overlay">
|
| 24 |
+
<div class="modal-content">
|
| 25 |
+
<button class="close-modal">×</button>
|
| 26 |
+
<div class="modal-icon">
|
| 27 |
+
<i class="fas fa-check-circle"></i>
|
| 28 |
+
</div>
|
| 29 |
+
<h3 class="modal-title">Training Successful!</h3>
|
| 30 |
+
<p class="modal-message">
|
| 31 |
+
Model has been trained successfully. You can inspect the detailed metrics and experiments on DagsHub.
|
| 32 |
+
</p>
|
| 33 |
+
<div class="modal-actions">
|
| 34 |
+
<a href="https://dagshub.com/Inder-26/NetworkSecurity/experiments" target="_blank" class="btn btn-primary">
|
| 35 |
+
<i class="fas fa-external-link-alt"></i>
|
| 36 |
+
Check Experiments
|
| 37 |
+
</a>
|
| 38 |
+
</div>
|
| 39 |
+
</div>
|
| 40 |
+
</div>
|
| 41 |
+
`;
|
| 42 |
+
document.body.insertAdjacentHTML('beforeend', modalHtml);
|
| 43 |
+
|
| 44 |
+
// Modal Close Logic
|
| 45 |
+
document.querySelector('.close-modal').addEventListener('click', () => {
|
| 46 |
+
document.getElementById('success-modal').classList.remove('show');
|
| 47 |
+
// Optional: reload page when modal is closed to refresh any data
|
| 48 |
+
// window.location.reload();
|
| 49 |
+
});
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
trainBtn.addEventListener('click', async function() {
|
| 53 |
+
if (!confirm('Are you sure you want to start model training? This may take a few minutes.')) {
|
| 54 |
+
return;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
const originalText = trainBtn.innerHTML;
|
| 58 |
+
trainBtn.disabled = true;
|
| 59 |
+
trainBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Training in Progress...';
|
| 60 |
+
|
| 61 |
+
try {
|
| 62 |
+
showNotification('Training started. Please wait...', 'info');
|
| 63 |
+
|
| 64 |
+
const response = await fetch('/api/train', {
|
| 65 |
+
method: 'POST'
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
const data = await response.json();
|
| 69 |
+
|
| 70 |
+
if (response.ok) {
|
| 71 |
+
// Show Modal
|
| 72 |
+
const modal = document.getElementById('success-modal');
|
| 73 |
+
modal.classList.add('show');
|
| 74 |
+
|
| 75 |
+
// Reset button
|
| 76 |
+
trainBtn.disabled = false;
|
| 77 |
+
trainBtn.innerHTML = originalText;
|
| 78 |
+
|
| 79 |
+
} else {
|
| 80 |
+
throw new Error(data.detail || 'Training failed');
|
| 81 |
+
}
|
| 82 |
+
} catch (error) {
|
| 83 |
+
console.error('Training Error:', error);
|
| 84 |
+
showNotification(`Training failed: ${error.message}`, 'error');
|
| 85 |
+
trainBtn.disabled = false;
|
| 86 |
+
trainBtn.innerHTML = originalText;
|
| 87 |
+
}
|
| 88 |
+
});
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// ============================================
|
| 92 |
+
// File Upload Handling
|
| 93 |
+
// ============================================
|
| 94 |
+
|
| 95 |
+
function initFileUpload() {
|
| 96 |
+
const uploadZone = document.getElementById('upload-zone');
|
| 97 |
+
const fileInput = document.getElementById('file-input');
|
| 98 |
+
const fileInfo = document.getElementById('file-info');
|
| 99 |
+
const fileName = document.getElementById('file-name');
|
| 100 |
+
const removeBtn = document.getElementById('remove-file');
|
| 101 |
+
const submitBtn = document.getElementById('submit-btn');
|
| 102 |
+
const form = document.getElementById('upload-form');
|
| 103 |
+
|
| 104 |
+
if (!uploadZone) return;
|
| 105 |
+
|
| 106 |
+
// Drag and drop
|
| 107 |
+
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
| 108 |
+
uploadZone.addEventListener(eventName, preventDefaults, false);
|
| 109 |
+
});
|
| 110 |
+
|
| 111 |
+
function preventDefaults(e) {
|
| 112 |
+
e.preventDefault();
|
| 113 |
+
e.stopPropagation();
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
['dragenter', 'dragover'].forEach(eventName => {
|
| 117 |
+
uploadZone.addEventListener(eventName, () => {
|
| 118 |
+
uploadZone.classList.add('dragover');
|
| 119 |
+
}, false);
|
| 120 |
+
});
|
| 121 |
+
|
| 122 |
+
['dragleave', 'drop'].forEach(eventName => {
|
| 123 |
+
uploadZone.addEventListener(eventName, () => {
|
| 124 |
+
uploadZone.classList.remove('dragover');
|
| 125 |
+
}, false);
|
| 126 |
+
});
|
| 127 |
+
|
| 128 |
+
uploadZone.addEventListener('drop', handleDrop, false);
|
| 129 |
+
|
| 130 |
+
function handleDrop(e) {
|
| 131 |
+
const dt = e.dataTransfer;
|
| 132 |
+
const files = dt.files;
|
| 133 |
+
|
| 134 |
+
if (files.length > 0) {
|
| 135 |
+
fileInput.files = files;
|
| 136 |
+
handleFileSelect(files[0]);
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
// File input change
|
| 141 |
+
fileInput.addEventListener('change', function(e) {
|
| 142 |
+
if (e.target.files.length > 0) {
|
| 143 |
+
handleFileSelect(e.target.files[0]);
|
| 144 |
+
}
|
| 145 |
+
});
|
| 146 |
+
|
| 147 |
+
function handleFileSelect(file) {
|
| 148 |
+
if (!file.name.endsWith('.csv')) {
|
| 149 |
+
showNotification('Please upload a CSV file', 'error');
|
| 150 |
+
return;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
fileName.textContent = file.name;
|
| 154 |
+
uploadZone.style.display = 'none';
|
| 155 |
+
fileInfo.style.display = 'flex';
|
| 156 |
+
submitBtn.disabled = false;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// Remove file
|
| 160 |
+
if (removeBtn) {
|
| 161 |
+
removeBtn.addEventListener('click', function() {
|
| 162 |
+
fileInput.value = '';
|
| 163 |
+
uploadZone.style.display = 'block';
|
| 164 |
+
fileInfo.style.display = 'none';
|
| 165 |
+
submitBtn.disabled = true;
|
| 166 |
+
});
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
// Form submit
|
| 170 |
+
if (form) {
|
| 171 |
+
form.addEventListener('submit', function(e) {
|
| 172 |
+
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Analyzing...';
|
| 173 |
+
submitBtn.disabled = true;
|
| 174 |
+
});
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
// ============================================
|
| 179 |
+
// Notifications
|
| 180 |
+
// ============================================
|
| 181 |
+
|
| 182 |
+
function showNotification(message, type = 'info') {
|
| 183 |
+
const notification = document.createElement('div');
|
| 184 |
+
notification.className = `notification notification-${type}`;
|
| 185 |
+
notification.innerHTML = `
|
| 186 |
+
<i class="fas fa-${type === 'error' ? 'exclamation-circle' : 'info-circle'}"></i>
|
| 187 |
+
<span>${message}</span>
|
| 188 |
+
`;
|
| 189 |
+
|
| 190 |
+
document.body.appendChild(notification);
|
| 191 |
+
|
| 192 |
+
setTimeout(() => {
|
| 193 |
+
notification.classList.add('show');
|
| 194 |
+
}, 100);
|
| 195 |
+
|
| 196 |
+
setTimeout(() => {
|
| 197 |
+
notification.classList.remove('show');
|
| 198 |
+
setTimeout(() => notification.remove(), 300);
|
| 199 |
+
}, 3000);
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
// ============================================
|
| 203 |
+
// Animations
|
| 204 |
+
// ============================================
|
| 205 |
+
|
| 206 |
+
function initAnimations() {
|
| 207 |
+
// Animate elements on scroll
|
| 208 |
+
const observerOptions = {
|
| 209 |
+
threshold: 0.1,
|
| 210 |
+
rootMargin: '0px 0px -50px 0px'
|
| 211 |
+
};
|
| 212 |
+
|
| 213 |
+
const observer = new IntersectionObserver((entries) => {
|
| 214 |
+
entries.forEach(entry => {
|
| 215 |
+
if (entry.isIntersecting) {
|
| 216 |
+
entry.target.classList.add('animate-in');
|
| 217 |
+
observer.unobserve(entry.target);
|
| 218 |
+
}
|
| 219 |
+
});
|
| 220 |
+
}, observerOptions);
|
| 221 |
+
|
| 222 |
+
document.querySelectorAll('.card').forEach(card => {
|
| 223 |
+
observer.observe(card);
|
| 224 |
+
});
|
| 225 |
+
|
| 226 |
+
// Animate metric circles
|
| 227 |
+
document.querySelectorAll('.metric-circle').forEach(circle => {
|
| 228 |
+
const progress = circle.style.getPropertyValue('--progress');
|
| 229 |
+
circle.style.setProperty('--progress', '0');
|
| 230 |
+
|
| 231 |
+
setTimeout(() => {
|
| 232 |
+
circle.style.transition = 'all 1s ease-out';
|
| 233 |
+
circle.style.setProperty('--progress', progress);
|
| 234 |
+
}, 300);
|
| 235 |
+
});
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
function initDynamicWidths() {
|
| 239 |
+
const dynamicElements = document.querySelectorAll('[data-width]');
|
| 240 |
+
|
| 241 |
+
dynamicElements.forEach(el => {
|
| 242 |
+
const width = el.getAttribute('data-width');
|
| 243 |
+
if (width) {
|
| 244 |
+
// Apply immediately if it's not an animated element, or let CSS transitions handle it
|
| 245 |
+
// We set it as a style property so the browser sees it as valid CSS
|
| 246 |
+
setTimeout(() => {
|
| 247 |
+
el.style.width = `${width}%`;
|
| 248 |
+
}, 100); // Small delay to ensure transitions work if present
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
// ============================================
|
| 254 |
+
// Utility Functions
|
| 255 |
+
// ============================================
|
| 256 |
+
|
| 257 |
+
function formatNumber(num) {
|
| 258 |
+
return new Intl.NumberFormat().format(num);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
function debounce(func, wait) {
|
| 262 |
+
let timeout;
|
| 263 |
+
return function executedFunction(...args) {
|
| 264 |
+
const later = () => {
|
| 265 |
+
clearTimeout(timeout);
|
| 266 |
+
func(...args);
|
| 267 |
+
};
|
| 268 |
+
clearTimeout(timeout);
|
| 269 |
+
timeout = setTimeout(later, wait);
|
| 270 |
+
};
|
| 271 |
+
}
|
templates/index.html
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>{{ title }}</title>
|
| 7 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
| 8 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
|
| 9 |
+
<link rel="stylesheet" href="/static/css/style.css">
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<!-- Header -->
|
| 13 |
+
<header class="header">
|
| 14 |
+
<div class="container">
|
| 15 |
+
<div class="header-content">
|
| 16 |
+
<a href="/" class="logo">
|
| 17 |
+
<i class="fas fa-shield-alt"></i>
|
| 18 |
+
<span>Network Security</span>
|
| 19 |
+
</a>
|
| 20 |
+
<nav class="nav-links">
|
| 21 |
+
<a href="/manual" class="nav-link">
|
| 22 |
+
<i class="fas fa-keyboard"></i>
|
| 23 |
+
<span>Manual Input</span>
|
| 24 |
+
</a>
|
| 25 |
+
<a href="{{ github_url }}" target="_blank" class="nav-link">
|
| 26 |
+
<i class="fab fa-github"></i>
|
| 27 |
+
<span>GitHub</span>
|
| 28 |
+
</a>
|
| 29 |
+
<a href="{{ dagshub_url }}" target="_blank" class="nav-link">
|
| 30 |
+
<i class="fas fa-flask"></i>
|
| 31 |
+
<span>DagsHub</span>
|
| 32 |
+
</a>
|
| 33 |
+
</nav>
|
| 34 |
+
</div>
|
| 35 |
+
</div>
|
| 36 |
+
</header>
|
| 37 |
+
|
| 38 |
+
<!-- Hero Section -->
|
| 39 |
+
<section class="hero">
|
| 40 |
+
<div class="container">
|
| 41 |
+
<div class="hero-content">
|
| 42 |
+
<div class="hero-badge">
|
| 43 |
+
<i class="fas fa-robot"></i>
|
| 44 |
+
<span>ML-Powered Security</span>
|
| 45 |
+
</div>
|
| 46 |
+
<h1>🛡️ Phishing URL Detection</h1>
|
| 47 |
+
<p class="hero-subtitle">
|
| 48 |
+
Protect your network with AI-powered threat detection.
|
| 49 |
+
Analyze URLs using 30 security features and machine learning.
|
| 50 |
+
</p>
|
| 51 |
+
<div class="hero-stats">
|
| 52 |
+
<div class="stat-card">
|
| 53 |
+
<div class="stat-icon">
|
| 54 |
+
<i class="fas fa-brain"></i>
|
| 55 |
+
</div>
|
| 56 |
+
<div class="stat-info">
|
| 57 |
+
<span class="stat-value">{{ metrics.model_name }}</span>
|
| 58 |
+
<span class="stat-label">Best Model</span>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
<div class="stat-card">
|
| 62 |
+
<div class="stat-icon">
|
| 63 |
+
<i class="fas fa-bullseye"></i>
|
| 64 |
+
</div>
|
| 65 |
+
<div class="stat-info">
|
| 66 |
+
<span class="stat-value">{{ "%.1f"|format(metrics.f1_score * 100) }}%</span>
|
| 67 |
+
<span class="stat-label">F1 Score</span>
|
| 68 |
+
</div>
|
| 69 |
+
</div>
|
| 70 |
+
<div class="stat-card">
|
| 71 |
+
<div class="stat-icon">
|
| 72 |
+
<i class="fas fa-columns"></i>
|
| 73 |
+
</div>
|
| 74 |
+
<div class="stat-info">
|
| 75 |
+
<span class="stat-value">{{ feature_count }}</span>
|
| 76 |
+
<span class="stat-label">Features</span>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
<div class="stat-card">
|
| 80 |
+
<div class="stat-icon">
|
| 81 |
+
<i class="fas fa-layer-group"></i>
|
| 82 |
+
</div>
|
| 83 |
+
<div class="stat-info">
|
| 84 |
+
<span class="stat-value">5</span>
|
| 85 |
+
<span class="stat-label">ML Models</span>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
</section>
|
| 92 |
+
|
| 93 |
+
<!-- Main Content -->
|
| 94 |
+
<main class="main-content">
|
| 95 |
+
<div class="container">
|
| 96 |
+
|
| 97 |
+
<!-- Prediction Options -->
|
| 98 |
+
<div class="prediction-options">
|
| 99 |
+
<h2 class="section-title">
|
| 100 |
+
<i class="fas fa-magic"></i>
|
| 101 |
+
Choose Prediction Method
|
| 102 |
+
</h2>
|
| 103 |
+
<div class="options-grid">
|
| 104 |
+
<!-- Train Model -->
|
| 105 |
+
<div class="card train-card">
|
| 106 |
+
<div class="card-icon">
|
| 107 |
+
<i class="fas fa-hammer"></i>
|
| 108 |
+
</div>
|
| 109 |
+
<h3>Train New Model</h3>
|
| 110 |
+
<p>Trigger a new training pipeline to update the model</p>
|
| 111 |
+
<button id="train-btn" class="btn btn-warning btn-block">
|
| 112 |
+
<i class="fas fa-play"></i>
|
| 113 |
+
Start Training
|
| 114 |
+
</button>
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+
<!-- Upload CSV -->
|
| 118 |
+
<div class="card upload-card">
|
| 119 |
+
<div class="card-icon">
|
| 120 |
+
<i class="fas fa-file-upload"></i>
|
| 121 |
+
</div>
|
| 122 |
+
<h3>Batch Prediction</h3>
|
| 123 |
+
<p>Upload a CSV file containing URL features for bulk analysis</p>
|
| 124 |
+
<form id="upload-form" action="/predict" method="post" enctype="multipart/form-data">
|
| 125 |
+
<div id="upload-zone" class="upload-zone">
|
| 126 |
+
<div class="upload-content">
|
| 127 |
+
<i class="fas fa-cloud-upload-alt"></i>
|
| 128 |
+
<p>Drag & Drop CSV file here</p>
|
| 129 |
+
<span>or click to browse</span>
|
| 130 |
+
</div>
|
| 131 |
+
<input type="file" name="file" id="file-input" accept=".csv" required>
|
| 132 |
+
</div>
|
| 133 |
+
<div id="file-info" class="file-info">
|
| 134 |
+
<i class="fas fa-file-csv"></i>
|
| 135 |
+
<span id="file-name">filename.csv</span>
|
| 136 |
+
<button type="button" id="remove-file" class="btn-remove">
|
| 137 |
+
<i class="fas fa-times"></i>
|
| 138 |
+
</button>
|
| 139 |
+
</div>
|
| 140 |
+
<button type="submit" id="submit-btn" class="btn btn-primary btn-block" disabled>
|
| 141 |
+
<i class="fas fa-search"></i>
|
| 142 |
+
Analyze File
|
| 143 |
+
</button>
|
| 144 |
+
</form>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<!-- Manual Input -->
|
| 148 |
+
<div class="card manual-card">
|
| 149 |
+
<div class="card-icon">
|
| 150 |
+
<i class="fas fa-keyboard"></i>
|
| 151 |
+
</div>
|
| 152 |
+
<h3>Manual Input</h3>
|
| 153 |
+
<p>Enter URL features manually to check for phishing</p>
|
| 154 |
+
<div class="manual-preview">
|
| 155 |
+
<div class="feature-preview">
|
| 156 |
+
<span class="feature-name">having_IP_Address</span>
|
| 157 |
+
<span class="feature-values">-1 / 0 / 1</span>
|
| 158 |
+
</div>
|
| 159 |
+
<div class="feature-preview">
|
| 160 |
+
<span class="feature-name">URL_Length</span>
|
| 161 |
+
<span class="feature-values">-1 / 0 / 1</span>
|
| 162 |
+
</div>
|
| 163 |
+
<div class="feature-preview">
|
| 164 |
+
<span class="feature-name">SSLfinal_State</span>
|
| 165 |
+
<span class="feature-values">-1 / 0 / 1</span>
|
| 166 |
+
</div>
|
| 167 |
+
<div class="more-features">
|
| 168 |
+
<span>+ 27 more features</span>
|
| 169 |
+
</div>
|
| 170 |
+
</div>
|
| 171 |
+
<a href="/manual" class="btn btn-secondary btn-block">
|
| 172 |
+
<i class="fas fa-edit"></i>
|
| 173 |
+
Open Manual Input
|
| 174 |
+
</a>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
|
| 179 |
+
<!-- Model Performance Comparison (Removed as per user request to reduce clutter) -->
|
| 180 |
+
<!-- Real-time stats are shown in the Hero section -->
|
| 181 |
+
|
| 182 |
+
<!-- Features Section -->
|
| 183 |
+
<div class="card features-card">
|
| 184 |
+
<div class="card-header">
|
| 185 |
+
<i class="fas fa-list-check"></i>
|
| 186 |
+
<h2>Required Features (30 Columns)</h2>
|
| 187 |
+
</div>
|
| 188 |
+
<div class="card-body">
|
| 189 |
+
<div class="features-grid">
|
| 190 |
+
<div class="feature-group">
|
| 191 |
+
<h4><i class="fas fa-link"></i> URL Structure</h4>
|
| 192 |
+
<ul>
|
| 193 |
+
<li><code>having_IP_Address</code></li>
|
| 194 |
+
<li><code>URL_Length</code></li>
|
| 195 |
+
<li><code>Shortining_Service</code></li>
|
| 196 |
+
<li><code>having_At_Symbol</code></li>
|
| 197 |
+
<li><code>double_slash_redirecting</code></li>
|
| 198 |
+
<li><code>Prefix_Suffix</code></li>
|
| 199 |
+
<li><code>having_Sub_Domain</code></li>
|
| 200 |
+
<li><code>Abnormal_URL</code></li>
|
| 201 |
+
</ul>
|
| 202 |
+
</div>
|
| 203 |
+
<div class="feature-group">
|
| 204 |
+
<h4><i class="fas fa-lock"></i> Security</h4>
|
| 205 |
+
<ul>
|
| 206 |
+
<li><code>SSLfinal_State</code></li>
|
| 207 |
+
<li><code>HTTPS_token</code></li>
|
| 208 |
+
<li><code>port</code></li>
|
| 209 |
+
<li><code>Favicon</code></li>
|
| 210 |
+
<li><code>Statistical_report</code></li>
|
| 211 |
+
</ul>
|
| 212 |
+
</div>
|
| 213 |
+
<div class="feature-group">
|
| 214 |
+
<h4><i class="fas fa-code"></i> Page Content</h4>
|
| 215 |
+
<ul>
|
| 216 |
+
<li><code>Request_URL</code></li>
|
| 217 |
+
<li><code>URL_of_Anchor</code></li>
|
| 218 |
+
<li><code>Links_in_tags</code></li>
|
| 219 |
+
<li><code>SFH</code></li>
|
| 220 |
+
<li><code>Submitting_to_email</code></li>
|
| 221 |
+
</ul>
|
| 222 |
+
</div>
|
| 223 |
+
<div class="feature-group">
|
| 224 |
+
<h4><i class="fas fa-mouse-pointer"></i> Page Behavior</h4>
|
| 225 |
+
<ul>
|
| 226 |
+
<li><code>Redirect</code></li>
|
| 227 |
+
<li><code>on_mouseover</code></li>
|
| 228 |
+
<li><code>RightClick</code></li>
|
| 229 |
+
<li><code>popUpWidnow</code></li>
|
| 230 |
+
<li><code>Iframe</code></li>
|
| 231 |
+
</ul>
|
| 232 |
+
</div>
|
| 233 |
+
<div class="feature-group">
|
| 234 |
+
<h4><i class="fas fa-globe"></i> Domain Info</h4>
|
| 235 |
+
<ul>
|
| 236 |
+
<li><code>Domain_registeration_length</code></li>
|
| 237 |
+
<li><code>age_of_domain</code></li>
|
| 238 |
+
<li><code>DNSRecord</code></li>
|
| 239 |
+
<li><code>web_traffic</code></li>
|
| 240 |
+
<li><code>Page_Rank</code></li>
|
| 241 |
+
<li><code>Google_Index</code></li>
|
| 242 |
+
<li><code>Links_pointing_to_page</code></li>
|
| 243 |
+
</ul>
|
| 244 |
+
</div>
|
| 245 |
+
</div>
|
| 246 |
+
<div class="feature-note">
|
| 247 |
+
<i class="fas fa-info-circle"></i>
|
| 248 |
+
<div>
|
| 249 |
+
<strong>Value Range:</strong> All features should be integers with values:
|
| 250 |
+
<code>-1</code> (Phishing indicator),
|
| 251 |
+
<code>0</code> (Suspicious), or
|
| 252 |
+
<code>1</code> (Legitimate indicator)
|
| 253 |
+
</div>
|
| 254 |
+
</div>
|
| 255 |
+
</div>
|
| 256 |
+
</div>
|
| 257 |
+
|
| 258 |
+
<!-- How It Works -->
|
| 259 |
+
<div class="card how-it-works-card">
|
| 260 |
+
<div class="card-header">
|
| 261 |
+
<i class="fas fa-cogs"></i>
|
| 262 |
+
<h2>How It Works</h2>
|
| 263 |
+
</div>
|
| 264 |
+
<div class="card-body">
|
| 265 |
+
<div class="pipeline-steps">
|
| 266 |
+
<div class="pipeline-step">
|
| 267 |
+
<div class="step-number">1</div>
|
| 268 |
+
<div class="step-icon"><i class="fas fa-database"></i></div>
|
| 269 |
+
<h4>Data Ingestion</h4>
|
| 270 |
+
<p>Raw data pulled from MongoDB and split into train/test sets</p>
|
| 271 |
+
</div>
|
| 272 |
+
<div class="pipeline-arrow"><i class="fas fa-arrow-right"></i></div>
|
| 273 |
+
<div class="pipeline-step">
|
| 274 |
+
<div class="step-number">2</div>
|
| 275 |
+
<div class="step-icon"><i class="fas fa-check-double"></i></div>
|
| 276 |
+
<h4>Validation</h4>
|
| 277 |
+
<p>Schema validation & KS drift detection</p>
|
| 278 |
+
</div>
|
| 279 |
+
<div class="pipeline-arrow"><i class="fas fa-arrow-right"></i></div>
|
| 280 |
+
<div class="pipeline-step">
|
| 281 |
+
<div class="step-number">3</div>
|
| 282 |
+
<div class="step-icon"><i class="fas fa-random"></i></div>
|
| 283 |
+
<h4>Transformation</h4>
|
| 284 |
+
<p>KNN Imputation & target mapping</p>
|
| 285 |
+
</div>
|
| 286 |
+
<div class="pipeline-arrow"><i class="fas fa-arrow-right"></i></div>
|
| 287 |
+
<div class="pipeline-step">
|
| 288 |
+
<div class="step-number">4</div>
|
| 289 |
+
<div class="step-icon"><i class="fas fa-robot"></i></div>
|
| 290 |
+
<h4>Model Training</h4>
|
| 291 |
+
<p>5 models evaluated, best selected by F1 score</p>
|
| 292 |
+
</div>
|
| 293 |
+
<div class="pipeline-arrow"><i class="fas fa-arrow-right"></i></div>
|
| 294 |
+
<div class="pipeline-step">
|
| 295 |
+
<div class="step-number">5</div>
|
| 296 |
+
<div class="step-icon"><i class="fas fa-rocket"></i></div>
|
| 297 |
+
<h4>Deployment</h4>
|
| 298 |
+
<p>Model served via FastAPI on Hugging Face</p>
|
| 299 |
+
</div>
|
| 300 |
+
</div>
|
| 301 |
+
</div>
|
| 302 |
+
</div>
|
| 303 |
+
|
| 304 |
+
</div>
|
| 305 |
+
</main>
|
| 306 |
+
|
| 307 |
+
<!-- Footer -->
|
| 308 |
+
<footer class="footer">
|
| 309 |
+
<div class="container">
|
| 310 |
+
<div class="footer-content">
|
| 311 |
+
<div class="footer-left">
|
| 312 |
+
<div class="footer-logo">
|
| 313 |
+
<i class="fas fa-shield-alt"></i>
|
| 314 |
+
<span>Network Security</span>
|
| 315 |
+
</div>
|
| 316 |
+
<p>Built with ❤️ by <strong>Inderjeet</strong></p>
|
| 317 |
+
<p class="footer-tech">
|
| 318 |
+
<span><i class="fab fa-python"></i> Python</span>
|
| 319 |
+
<span><i class="fas fa-bolt"></i> FastAPI</span>
|
| 320 |
+
<span><i class="fas fa-chart-line"></i> MLflow</span>
|
| 321 |
+
<span><i class="fas fa-database"></i> MongoDB</span>
|
| 322 |
+
</p>
|
| 323 |
+
</div>
|
| 324 |
+
<div class="footer-right">
|
| 325 |
+
<a href="https://github.com/Inder-26/NetworkSecurity" target="_blank" title="GitHub">
|
| 326 |
+
<i class="fab fa-github"></i>
|
| 327 |
+
</a>
|
| 328 |
+
<a href="https://dagshub.com/inder-26/NetworkSecurity" target="_blank" title="DagsHub">
|
| 329 |
+
<i class="fas fa-flask"></i>
|
| 330 |
+
</a>
|
| 331 |
+
<a href="https://www.linkedin.com/in/inderjeet-singh-26n/" target="_blank" title="LinkedIn">
|
| 332 |
+
<i class="fab fa-linkedin"></i>
|
| 333 |
+
</a>
|
| 334 |
+
</div>
|
| 335 |
+
</div>
|
| 336 |
+
</div>
|
| 337 |
+
</footer>
|
| 338 |
+
|
| 339 |
+
<script src="/static/js/main.js"></script>
|
| 340 |
+
</body>
|
| 341 |
+
</html>
|
templates/predict.html
CHANGED
|
@@ -1,21 +1,230 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html>
|
| 3 |
<head>
|
| 4 |
-
<
|
| 5 |
-
<
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
th, td {
|
| 11 |
-
border: 1px solid black;
|
| 12 |
-
padding: 8px;
|
| 13 |
-
text-align: left;
|
| 14 |
-
}
|
| 15 |
-
</style>
|
| 16 |
</head>
|
| 17 |
<body>
|
| 18 |
-
<
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
</body>
|
| 21 |
</html>
|
|
|
|
| 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>{{ title }} - Network Security</title>
|
| 7 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
| 8 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
|
| 9 |
+
<link rel="stylesheet" href="/static/css/style.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
+
<!-- Header -->
|
| 13 |
+
<header class="header">
|
| 14 |
+
<div class="container">
|
| 15 |
+
<div class="header-content">
|
| 16 |
+
<a href="/" class="logo">
|
| 17 |
+
<i class="fas fa-shield-alt"></i>
|
| 18 |
+
<span>Network Security</span>
|
| 19 |
+
</a>
|
| 20 |
+
<nav class="nav-links">
|
| 21 |
+
<a href="/" class="nav-link">
|
| 22 |
+
<i class="fas fa-home"></i>
|
| 23 |
+
<span>Home</span>
|
| 24 |
+
</a>
|
| 25 |
+
<a href="{{ github_url }}" target="_blank" class="nav-link">
|
| 26 |
+
<i class="fab fa-github"></i>
|
| 27 |
+
<span>GitHub</span>
|
| 28 |
+
</a>
|
| 29 |
+
<a href="{{ dagshub_url }}" target="_blank" class="nav-link">
|
| 30 |
+
<i class="fas fa-flask"></i>
|
| 31 |
+
<span>DagsHub</span>
|
| 32 |
+
</a>
|
| 33 |
+
</nav>
|
| 34 |
+
</div>
|
| 35 |
+
</div>
|
| 36 |
+
</header>
|
| 37 |
+
|
| 38 |
+
<main class="main-content results-page">
|
| 39 |
+
<div class="container">
|
| 40 |
+
|
| 41 |
+
<!-- Results Header -->
|
| 42 |
+
<div class="results-header">
|
| 43 |
+
<div class="results-title">
|
| 44 |
+
<h1><i class="fas fa-chart-pie"></i> Prediction Results</h1>
|
| 45 |
+
<p>Analysis complete for {{ summary.total }} URLs</p>
|
| 46 |
+
</div>
|
| 47 |
+
<div class="results-actions">
|
| 48 |
+
<a href="/download/results/{{ output_filename }}" class="btn btn-primary">
|
| 49 |
+
<i class="fas fa-download"></i> Download CSV
|
| 50 |
+
</a>
|
| 51 |
+
<a href="/" class="btn btn-outline">
|
| 52 |
+
<i class="fas fa-plus"></i> New Analysis
|
| 53 |
+
</a>
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<!-- Summary Cards -->
|
| 58 |
+
<div class="summary-grid">
|
| 59 |
+
<div class="summary-card total">
|
| 60 |
+
<div class="summary-icon">
|
| 61 |
+
<i class="fas fa-list-ol"></i>
|
| 62 |
+
</div>
|
| 63 |
+
<div class="summary-info">
|
| 64 |
+
<span class="summary-value">{{ summary.total }}</span>
|
| 65 |
+
<span class="summary-label">Total URLs Analyzed</span>
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
|
| 69 |
+
<div class="summary-card safe">
|
| 70 |
+
<div class="summary-icon">
|
| 71 |
+
<i class="fas fa-check-circle"></i>
|
| 72 |
+
</div>
|
| 73 |
+
<div class="summary-info">
|
| 74 |
+
<span class="summary-value">{{ summary.legitimate }}</span>
|
| 75 |
+
<span class="summary-label">Legitimate URLs</span>
|
| 76 |
+
</div>
|
| 77 |
+
<div class="summary-percent">{{ ((summary.legitimate / summary.total) * 100)|round(1) }}%</div>
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
<div class="summary-card danger">
|
| 81 |
+
<div class="summary-icon">
|
| 82 |
+
<i class="fas fa-exclamation-triangle"></i>
|
| 83 |
+
</div>
|
| 84 |
+
<div class="summary-info">
|
| 85 |
+
<span class="summary-value">{{ summary.phishing }}</span>
|
| 86 |
+
<span class="summary-label">Phishing URLs</span>
|
| 87 |
+
</div>
|
| 88 |
+
<div class="summary-percent">{{ summary.phishing_percent }}%</div>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<div class="summary-card threat">
|
| 92 |
+
<div class="summary-icon">
|
| 93 |
+
<i class="fas fa-shield-alt"></i>
|
| 94 |
+
</div>
|
| 95 |
+
<div class="summary-info">
|
| 96 |
+
<span class="summary-value">
|
| 97 |
+
{% if summary.phishing_percent < 20 %}Low
|
| 98 |
+
{% elif summary.phishing_percent < 50 %}Medium
|
| 99 |
+
{% else %}High
|
| 100 |
+
{% endif %}
|
| 101 |
+
</span>
|
| 102 |
+
<span class="summary-label">Threat Level</span>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
<!-- Threat Visualization -->
|
| 108 |
+
<div class="card threat-card">
|
| 109 |
+
<div class="card-header">
|
| 110 |
+
<i class="fas fa-tachometer-alt"></i>
|
| 111 |
+
<h2>Threat Assessment</h2>
|
| 112 |
+
</div>
|
| 113 |
+
<div class="card-body">
|
| 114 |
+
<div class="threat-visual">
|
| 115 |
+
<div class="threat-bar-container">
|
| 116 |
+
<div class="threat-bar">
|
| 117 |
+
<div class="threat-segment safe" data-width="{{ ((summary.legitimate / summary.total) * 100)|round(1) }}">
|
| 118 |
+
<span>{{ summary.legitimate }} Safe</span>
|
| 119 |
+
</div>
|
| 120 |
+
<div class="threat-segment danger" data-width="{{ summary.phishing_percent }}">
|
| 121 |
+
<span>{{ summary.phishing }} Threats</span>
|
| 122 |
+
</div>
|
| 123 |
+
</div>
|
| 124 |
+
</div>
|
| 125 |
+
<div class="threat-message">
|
| 126 |
+
{% if summary.phishing_percent < 20 %}
|
| 127 |
+
<div class="message-safe">
|
| 128 |
+
<i class="fas fa-shield-alt"></i>
|
| 129 |
+
<p><strong>Low Risk:</strong> The majority of URLs appear to be legitimate. Continue with normal operations.</p>
|
| 130 |
+
</div>
|
| 131 |
+
{% elif summary.phishing_percent < 50 %}
|
| 132 |
+
<div class="message-warning">
|
| 133 |
+
<i class="fas fa-exclamation-circle"></i>
|
| 134 |
+
<p><strong>Moderate Risk:</strong> Some URLs show phishing characteristics. Review flagged URLs before accessing.</p>
|
| 135 |
+
</div>
|
| 136 |
+
{% else %}
|
| 137 |
+
<div class="message-danger">
|
| 138 |
+
<i class="fas fa-skull-crossbones"></i>
|
| 139 |
+
<p><strong>High Risk:</strong> Many URLs are potentially malicious. Avoid clicking on flagged links.</p>
|
| 140 |
+
</div>
|
| 141 |
+
{% endif %}
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<!-- Results Table -->
|
| 148 |
+
<div class="card table-card">
|
| 149 |
+
<div class="card-header">
|
| 150 |
+
<i class="fas fa-table"></i>
|
| 151 |
+
<h2>Detailed Results</h2>
|
| 152 |
+
<span class="record-count">{{ summary.total }} records</span>
|
| 153 |
+
</div>
|
| 154 |
+
<div class="card-body">
|
| 155 |
+
<div class="table-wrapper">
|
| 156 |
+
<table class="results-table">
|
| 157 |
+
<thead>
|
| 158 |
+
<tr>
|
| 159 |
+
<th class="col-index">#</th>
|
| 160 |
+
{% for col in columns %}
|
| 161 |
+
<th>{{ col }}</th>
|
| 162 |
+
{% endfor %}
|
| 163 |
+
</tr>
|
| 164 |
+
</thead>
|
| 165 |
+
<tbody>
|
| 166 |
+
{% for row in results %}
|
| 167 |
+
<tr class="{{ 'row-danger' if row.Prediction == 1 else 'row-safe' }}">
|
| 168 |
+
<td class="col-index">{{ loop.index }}</td>
|
| 169 |
+
{% for col in columns %}
|
| 170 |
+
<td>
|
| 171 |
+
{% if col == 'Label' %}
|
| 172 |
+
<span class="label-badge {{ 'danger' if 'Phishing' in row[col] else 'success' }}">
|
| 173 |
+
{{ row[col] }}
|
| 174 |
+
</span>
|
| 175 |
+
{% elif col == 'Confidence' %}
|
| 176 |
+
<div class="confidence-bar">
|
| 177 |
+
<div class="confidence-fill" data-width="{{ row[col] }}"></div>
|
| 178 |
+
<span>{{ row[col] }}%</span>
|
| 179 |
+
</div>
|
| 180 |
+
{% elif col == 'Prediction' %}
|
| 181 |
+
<span class="prediction-value {{ 'danger' if row[col] == 1 else 'success' }}">
|
| 182 |
+
{{ row[col] }}
|
| 183 |
+
</span>
|
| 184 |
+
{% else %}
|
| 185 |
+
{{ row[col] }}
|
| 186 |
+
{% endif %}
|
| 187 |
+
</td>
|
| 188 |
+
{% endfor %}
|
| 189 |
+
</tr>
|
| 190 |
+
{% endfor %}
|
| 191 |
+
</tbody>
|
| 192 |
+
</table>
|
| 193 |
+
</div>
|
| 194 |
+
</div>
|
| 195 |
+
</div>
|
| 196 |
+
|
| 197 |
+
<!-- Actions -->
|
| 198 |
+
<div class="bottom-actions">
|
| 199 |
+
<a href="/" class="btn btn-primary btn-lg">
|
| 200 |
+
<i class="fas fa-redo"></i> Analyze More URLs
|
| 201 |
+
</a>
|
| 202 |
+
<a href="/download/results/{{ output_filename }}" class="btn btn-outline btn-lg">
|
| 203 |
+
<i class="fas fa-file-csv"></i> Export Full Report
|
| 204 |
+
</a>
|
| 205 |
+
<a href="/manual" class="btn btn-outline btn-lg">
|
| 206 |
+
<i class="fas fa-keyboard"></i> Try Manual Input
|
| 207 |
+
</a>
|
| 208 |
+
</div>
|
| 209 |
+
|
| 210 |
+
</div>
|
| 211 |
+
</main>
|
| 212 |
+
|
| 213 |
+
<!-- Footer -->
|
| 214 |
+
<footer class="footer">
|
| 215 |
+
<div class="container">
|
| 216 |
+
<div class="footer-content">
|
| 217 |
+
<div class="footer-left">
|
| 218 |
+
<p>Built with ❤️ by <strong>Inderjeet</strong></p>
|
| 219 |
+
</div>
|
| 220 |
+
<div class="footer-right">
|
| 221 |
+
<a href="{{ github_url }}" target="_blank"><i class="fab fa-github"></i></a>
|
| 222 |
+
<a href="{{ dagshub_url }}" target="_blank"><i class="fas fa-flask"></i></a>
|
| 223 |
+
</div>
|
| 224 |
+
</div>
|
| 225 |
+
</div>
|
| 226 |
+
</footer>
|
| 227 |
+
|
| 228 |
+
<script src="/static/js/main.js"></script>
|
| 229 |
</body>
|
| 230 |
</html>
|
templates/single_predict.html
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>{{ title }} - Network Security</title>
|
| 7 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
| 8 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
|
| 9 |
+
<link rel="stylesheet" href="/static/css/style.css">
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<!-- Header -->
|
| 13 |
+
<header class="header">
|
| 14 |
+
<div class="container">
|
| 15 |
+
<div class="header-content">
|
| 16 |
+
<a href="/" class="logo">
|
| 17 |
+
<i class="fas fa-shield-alt"></i>
|
| 18 |
+
<span>Network Security</span>
|
| 19 |
+
</a>
|
| 20 |
+
<nav class="nav-links">
|
| 21 |
+
<a href="/" class="nav-link">
|
| 22 |
+
<i class="fas fa-home"></i>
|
| 23 |
+
<span>Home</span>
|
| 24 |
+
</a>
|
| 25 |
+
<a href="{{ github_url }}" target="_blank" class="nav-link">
|
| 26 |
+
<i class="fab fa-github"></i>
|
| 27 |
+
<span>GitHub</span>
|
| 28 |
+
</a>
|
| 29 |
+
<a href="{{ dagshub_url }}" target="_blank" class="nav-link">
|
| 30 |
+
<i class="fas fa-flask"></i>
|
| 31 |
+
<span>DagsHub</span>
|
| 32 |
+
</a>
|
| 33 |
+
</nav>
|
| 34 |
+
</div>
|
| 35 |
+
</div>
|
| 36 |
+
</header>
|
| 37 |
+
|
| 38 |
+
<main class="main-content manual-page">
|
| 39 |
+
<div class="container">
|
| 40 |
+
|
| 41 |
+
<!-- Page Header -->
|
| 42 |
+
<div class="page-header">
|
| 43 |
+
<h1><i class="fas fa-keyboard"></i> Manual Feature Input</h1>
|
| 44 |
+
<p>Enter the 30 feature values to predict if a URL is phishing or legitimate</p>
|
| 45 |
+
</div>
|
| 46 |
+
|
| 47 |
+
<!-- Result Display (if prediction was made) -->
|
| 48 |
+
{% if result %}
|
| 49 |
+
<div class="result-card {{ 'result-danger' if result.is_threat else 'result-safe' }}">
|
| 50 |
+
<div class="result-icon">
|
| 51 |
+
{% if result.is_threat %}
|
| 52 |
+
<i class="fas fa-exclamation-triangle"></i>
|
| 53 |
+
{% else %}
|
| 54 |
+
<i class="fas fa-check-circle"></i>
|
| 55 |
+
{% endif %}
|
| 56 |
+
</div>
|
| 57 |
+
<div class="result-content">
|
| 58 |
+
<h2>{{ result.label }}</h2>
|
| 59 |
+
<p>Confidence: <strong>{{ result.confidence }}%</strong></p>
|
| 60 |
+
</div>
|
| 61 |
+
<div class="result-action">
|
| 62 |
+
<a href="/manual" class="btn btn-outline">
|
| 63 |
+
<i class="fas fa-redo"></i> New Prediction
|
| 64 |
+
</a>
|
| 65 |
+
</div>
|
| 66 |
+
</div>
|
| 67 |
+
{% endif %}
|
| 68 |
+
|
| 69 |
+
<!-- Input Form -->
|
| 70 |
+
<form id="manual-form" action="/predict/single" method="post" class="manual-form">
|
| 71 |
+
|
| 72 |
+
<!-- Quick Actions -->
|
| 73 |
+
<div class="quick-actions">
|
| 74 |
+
<button type="button" class="btn btn-outline btn-sm" onclick="fillSample('legitimate')">
|
| 75 |
+
<i class="fas fa-check"></i> Fill Legitimate Sample
|
| 76 |
+
</button>
|
| 77 |
+
<button type="button" class="btn btn-outline btn-sm" onclick="fillSample('phishing')">
|
| 78 |
+
<i class="fas fa-bug"></i> Fill Phishing Sample
|
| 79 |
+
</button>
|
| 80 |
+
<button type="button" class="btn btn-outline btn-sm" onclick="clearForm()">
|
| 81 |
+
<i class="fas fa-eraser"></i> Clear All
|
| 82 |
+
</button>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<!-- Feature Groups -->
|
| 86 |
+
<div class="feature-groups">
|
| 87 |
+
|
| 88 |
+
<!-- URL Structure -->
|
| 89 |
+
<div class="feature-group-card">
|
| 90 |
+
<div class="group-header">
|
| 91 |
+
<i class="fas fa-link"></i>
|
| 92 |
+
<h3>URL Structure</h3>
|
| 93 |
+
</div>
|
| 94 |
+
<div class="inputs-grid">
|
| 95 |
+
<div class="input-item">
|
| 96 |
+
<label for="having_IP_Address">having_IP_Address</label>
|
| 97 |
+
<div class="radio-group">
|
| 98 |
+
<label class="radio-label">
|
| 99 |
+
<input type="radio" name="having_IP_Address" value="-1" {{ 'checked' if input_values and input_values.having_IP_Address == -1 }}>
|
| 100 |
+
<span class="radio-btn danger">-1</span>
|
| 101 |
+
</label>
|
| 102 |
+
<label class="radio-label">
|
| 103 |
+
<input type="radio" name="having_IP_Address" value="0" {{ 'checked' if not input_values or input_values.having_IP_Address == 0 }}>
|
| 104 |
+
<span class="radio-btn warning">0</span>
|
| 105 |
+
</label>
|
| 106 |
+
<label class="radio-label">
|
| 107 |
+
<input type="radio" name="having_IP_Address" value="1" {{ 'checked' if input_values and input_values.having_IP_Address == 1 }}>
|
| 108 |
+
<span class="radio-btn success">1</span>
|
| 109 |
+
</label>
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
<div class="input-item">
|
| 113 |
+
<label for="URL_Length">URL_Length</label>
|
| 114 |
+
<div class="radio-group">
|
| 115 |
+
<label class="radio-label">
|
| 116 |
+
<input type="radio" name="URL_Length" value="-1" {{ 'checked' if input_values and input_values.URL_Length == -1 }}>
|
| 117 |
+
<span class="radio-btn danger">-1</span>
|
| 118 |
+
</label>
|
| 119 |
+
<label class="radio-label">
|
| 120 |
+
<input type="radio" name="URL_Length" value="0" {{ 'checked' if not input_values or input_values.URL_Length == 0 }}>
|
| 121 |
+
<span class="radio-btn warning">0</span>
|
| 122 |
+
</label>
|
| 123 |
+
<label class="radio-label">
|
| 124 |
+
<input type="radio" name="URL_Length" value="1" {{ 'checked' if input_values and input_values.URL_Length == 1 }}>
|
| 125 |
+
<span class="radio-btn success">1</span>
|
| 126 |
+
</label>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
<div class="input-item">
|
| 130 |
+
<label for="Shortining_Service">Shortining_Service</label>
|
| 131 |
+
<div class="radio-group">
|
| 132 |
+
<label class="radio-label">
|
| 133 |
+
<input type="radio" name="Shortining_Service" value="-1">
|
| 134 |
+
<span class="radio-btn danger">-1</span>
|
| 135 |
+
</label>
|
| 136 |
+
<label class="radio-label">
|
| 137 |
+
<input type="radio" name="Shortining_Service" value="0" checked>
|
| 138 |
+
<span class="radio-btn warning">0</span>
|
| 139 |
+
</label>
|
| 140 |
+
<label class="radio-label">
|
| 141 |
+
<input type="radio" name="Shortining_Service" value="1">
|
| 142 |
+
<span class="radio-btn success">1</span>
|
| 143 |
+
</label>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
<div class="input-item">
|
| 147 |
+
<label for="having_At_Symbol">having_At_Symbol</label>
|
| 148 |
+
<div class="radio-group">
|
| 149 |
+
<label class="radio-label">
|
| 150 |
+
<input type="radio" name="having_At_Symbol" value="-1">
|
| 151 |
+
<span class="radio-btn danger">-1</span>
|
| 152 |
+
</label>
|
| 153 |
+
<label class="radio-label">
|
| 154 |
+
<input type="radio" name="having_At_Symbol" value="0" checked>
|
| 155 |
+
<span class="radio-btn warning">0</span>
|
| 156 |
+
</label>
|
| 157 |
+
<label class="radio-label">
|
| 158 |
+
<input type="radio" name="having_At_Symbol" value="1">
|
| 159 |
+
<span class="radio-btn success">1</span>
|
| 160 |
+
</label>
|
| 161 |
+
</div>
|
| 162 |
+
</div>
|
| 163 |
+
<div class="input-item">
|
| 164 |
+
<label for="double_slash_redirecting">double_slash_redirecting</label>
|
| 165 |
+
<div class="radio-group">
|
| 166 |
+
<label class="radio-label">
|
| 167 |
+
<input type="radio" name="double_slash_redirecting" value="-1">
|
| 168 |
+
<span class="radio-btn danger">-1</span>
|
| 169 |
+
</label>
|
| 170 |
+
<label class="radio-label">
|
| 171 |
+
<input type="radio" name="double_slash_redirecting" value="0" checked>
|
| 172 |
+
<span class="radio-btn warning">0</span>
|
| 173 |
+
</label>
|
| 174 |
+
<label class="radio-label">
|
| 175 |
+
<input type="radio" name="double_slash_redirecting" value="1">
|
| 176 |
+
<span class="radio-btn success">1</span>
|
| 177 |
+
</label>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
<div class="input-item">
|
| 181 |
+
<label for="Prefix_Suffix">Prefix_Suffix</label>
|
| 182 |
+
<div class="radio-group">
|
| 183 |
+
<label class="radio-label">
|
| 184 |
+
<input type="radio" name="Prefix_Suffix" value="-1">
|
| 185 |
+
<span class="radio-btn danger">-1</span>
|
| 186 |
+
</label>
|
| 187 |
+
<label class="radio-label">
|
| 188 |
+
<input type="radio" name="Prefix_Suffix" value="0" checked>
|
| 189 |
+
<span class="radio-btn warning">0</span>
|
| 190 |
+
</label>
|
| 191 |
+
<label class="radio-label">
|
| 192 |
+
<input type="radio" name="Prefix_Suffix" value="1">
|
| 193 |
+
<span class="radio-btn success">1</span>
|
| 194 |
+
</label>
|
| 195 |
+
</div>
|
| 196 |
+
</div>
|
| 197 |
+
<div class="input-item">
|
| 198 |
+
<label for="having_Sub_Domain">having_Sub_Domain</label>
|
| 199 |
+
<div class="radio-group">
|
| 200 |
+
<label class="radio-label">
|
| 201 |
+
<input type="radio" name="having_Sub_Domain" value="-1">
|
| 202 |
+
<span class="radio-btn danger">-1</span>
|
| 203 |
+
</label>
|
| 204 |
+
<label class="radio-label">
|
| 205 |
+
<input type="radio" name="having_Sub_Domain" value="0" checked>
|
| 206 |
+
<span class="radio-btn warning">0</span>
|
| 207 |
+
</label>
|
| 208 |
+
<label class="radio-label">
|
| 209 |
+
<input type="radio" name="having_Sub_Domain" value="1">
|
| 210 |
+
<span class="radio-btn success">1</span>
|
| 211 |
+
</label>
|
| 212 |
+
</div>
|
| 213 |
+
</div>
|
| 214 |
+
<div class="input-item">
|
| 215 |
+
<label for="Abnormal_URL">Abnormal_URL</label>
|
| 216 |
+
<div class="radio-group">
|
| 217 |
+
<label class="radio-label">
|
| 218 |
+
<input type="radio" name="Abnormal_URL" value="-1">
|
| 219 |
+
<span class="radio-btn danger">-1</span>
|
| 220 |
+
</label>
|
| 221 |
+
<label class="radio-label">
|
| 222 |
+
<input type="radio" name="Abnormal_URL" value="0" checked>
|
| 223 |
+
<span class="radio-btn warning">0</span>
|
| 224 |
+
</label>
|
| 225 |
+
<label class="radio-label">
|
| 226 |
+
<input type="radio" name="Abnormal_URL" value="1">
|
| 227 |
+
<span class="radio-btn success">1</span>
|
| 228 |
+
</label>
|
| 229 |
+
</div>
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
</div>
|
| 233 |
+
|
| 234 |
+
<!-- Security Features -->
|
| 235 |
+
<div class="feature-group-card">
|
| 236 |
+
<div class="group-header">
|
| 237 |
+
<i class="fas fa-lock"></i>
|
| 238 |
+
<h3>Security Features</h3>
|
| 239 |
+
</div>
|
| 240 |
+
<div class="inputs-grid">
|
| 241 |
+
{% for feature in ['SSLfinal_State', 'HTTPS_token', 'port', 'Favicon', 'Statistical_report'] %}
|
| 242 |
+
<div class="input-item">
|
| 243 |
+
<label for="{{ feature }}">{{ feature }}</label>
|
| 244 |
+
<div class="radio-group">
|
| 245 |
+
<label class="radio-label">
|
| 246 |
+
<input type="radio" name="{{ feature }}" value="-1">
|
| 247 |
+
<span class="radio-btn danger">-1</span>
|
| 248 |
+
</label>
|
| 249 |
+
<label class="radio-label">
|
| 250 |
+
<input type="radio" name="{{ feature }}" value="0" checked>
|
| 251 |
+
<span class="radio-btn warning">0</span>
|
| 252 |
+
</label>
|
| 253 |
+
<label class="radio-label">
|
| 254 |
+
<input type="radio" name="{{ feature }}" value="1">
|
| 255 |
+
<span class="radio-btn success">1</span>
|
| 256 |
+
</label>
|
| 257 |
+
</div>
|
| 258 |
+
</div>
|
| 259 |
+
{% endfor %}
|
| 260 |
+
</div>
|
| 261 |
+
</div>
|
| 262 |
+
|
| 263 |
+
<!-- Page Content Features -->
|
| 264 |
+
<div class="feature-group-card">
|
| 265 |
+
<div class="group-header">
|
| 266 |
+
<i class="fas fa-code"></i>
|
| 267 |
+
<h3>Page Content</h3>
|
| 268 |
+
</div>
|
| 269 |
+
<div class="inputs-grid">
|
| 270 |
+
{% for feature in ['Request_URL', 'URL_of_Anchor', 'Links_in_tags', 'SFH', 'Submitting_to_email'] %}
|
| 271 |
+
<div class="input-item">
|
| 272 |
+
<label for="{{ feature }}">{{ feature }}</label>
|
| 273 |
+
<div class="radio-group">
|
| 274 |
+
<label class="radio-label">
|
| 275 |
+
<input type="radio" name="{{ feature }}" value="-1">
|
| 276 |
+
<span class="radio-btn danger">-1</span>
|
| 277 |
+
</label>
|
| 278 |
+
<label class="radio-label">
|
| 279 |
+
<input type="radio" name="{{ feature }}" value="0" checked>
|
| 280 |
+
<span class="radio-btn warning">0</span>
|
| 281 |
+
</label>
|
| 282 |
+
<label class="radio-label">
|
| 283 |
+
<input type="radio" name="{{ feature }}" value="1">
|
| 284 |
+
<span class="radio-btn success">1</span>
|
| 285 |
+
</label>
|
| 286 |
+
</div>
|
| 287 |
+
</div>
|
| 288 |
+
{% endfor %}
|
| 289 |
+
</div>
|
| 290 |
+
</div>
|
| 291 |
+
|
| 292 |
+
<!-- Page Behavior Features -->
|
| 293 |
+
<div class="feature-group-card">
|
| 294 |
+
<div class="group-header">
|
| 295 |
+
<i class="fas fa-mouse-pointer"></i>
|
| 296 |
+
<h3>Page Behavior</h3>
|
| 297 |
+
</div>
|
| 298 |
+
<div class="inputs-grid">
|
| 299 |
+
{% for feature in ['Redirect', 'on_mouseover', 'RightClick', 'popUpWidnow', 'Iframe'] %}
|
| 300 |
+
<div class="input-item">
|
| 301 |
+
<label for="{{ feature }}">{{ feature }}</label>
|
| 302 |
+
<div class="radio-group">
|
| 303 |
+
<label class="radio-label">
|
| 304 |
+
<input type="radio" name="{{ feature }}" value="-1">
|
| 305 |
+
<span class="radio-btn danger">-1</span>
|
| 306 |
+
</label>
|
| 307 |
+
<label class="radio-label">
|
| 308 |
+
<input type="radio" name="{{ feature }}" value="0" checked>
|
| 309 |
+
<span class="radio-btn warning">0</span>
|
| 310 |
+
</label>
|
| 311 |
+
<label class="radio-label">
|
| 312 |
+
<input type="radio" name="{{ feature }}" value="1">
|
| 313 |
+
<span class="radio-btn success">1</span>
|
| 314 |
+
</label>
|
| 315 |
+
</div>
|
| 316 |
+
</div>
|
| 317 |
+
{% endfor %}
|
| 318 |
+
</div>
|
| 319 |
+
</div>
|
| 320 |
+
|
| 321 |
+
<!-- Domain Features -->
|
| 322 |
+
<div class="feature-group-card">
|
| 323 |
+
<div class="group-header">
|
| 324 |
+
<i class="fas fa-globe"></i>
|
| 325 |
+
<h3>Domain Information</h3>
|
| 326 |
+
</div>
|
| 327 |
+
<div class="inputs-grid">
|
| 328 |
+
{% for feature in ['Domain_registeration_length', 'age_of_domain', 'DNSRecord', 'web_traffic', 'Page_Rank', 'Google_Index', 'Links_pointing_to_page'] %}
|
| 329 |
+
<div class="input-item">
|
| 330 |
+
<label for="{{ feature }}">{{ feature }}</label>
|
| 331 |
+
<div class="radio-group">
|
| 332 |
+
<label class="radio-label">
|
| 333 |
+
<input type="radio" name="{{ feature }}" value="-1">
|
| 334 |
+
<span class="radio-btn danger">-1</span>
|
| 335 |
+
</label>
|
| 336 |
+
<label class="radio-label">
|
| 337 |
+
<input type="radio" name="{{ feature }}" value="0" checked>
|
| 338 |
+
<span class="radio-btn warning">0</span>
|
| 339 |
+
</label>
|
| 340 |
+
<label class="radio-label">
|
| 341 |
+
<input type="radio" name="{{ feature }}" value="1">
|
| 342 |
+
<span class="radio-btn success">1</span>
|
| 343 |
+
</label>
|
| 344 |
+
</div>
|
| 345 |
+
</div>
|
| 346 |
+
{% endfor %}
|
| 347 |
+
</div>
|
| 348 |
+
</div>
|
| 349 |
+
|
| 350 |
+
</div>
|
| 351 |
+
|
| 352 |
+
<!-- Submit Button -->
|
| 353 |
+
<div class="form-actions">
|
| 354 |
+
<button type="submit" class="btn btn-primary btn-lg">
|
| 355 |
+
<i class="fas fa-search"></i>
|
| 356 |
+
Predict URL Safety
|
| 357 |
+
</button>
|
| 358 |
+
</div>
|
| 359 |
+
|
| 360 |
+
</form>
|
| 361 |
+
|
| 362 |
+
<!-- Legend -->
|
| 363 |
+
<div class="legend-card">
|
| 364 |
+
<h4><i class="fas fa-info-circle"></i> Value Legend</h4>
|
| 365 |
+
<div class="legend-items">
|
| 366 |
+
<div class="legend-item">
|
| 367 |
+
<span class="legend-badge danger">-1</span>
|
| 368 |
+
<span>Indicates phishing characteristic</span>
|
| 369 |
+
</div>
|
| 370 |
+
<div class="legend-item">
|
| 371 |
+
<span class="legend-badge warning">0</span>
|
| 372 |
+
<span>Suspicious / Unknown</span>
|
| 373 |
+
</div>
|
| 374 |
+
<div class="legend-item">
|
| 375 |
+
<span class="legend-badge success">1</span>
|
| 376 |
+
<span>Indicates legitimate characteristic</span>
|
| 377 |
+
</div>
|
| 378 |
+
</div>
|
| 379 |
+
</div>
|
| 380 |
+
|
| 381 |
+
</div>
|
| 382 |
+
</main>
|
| 383 |
+
|
| 384 |
+
<!-- Footer -->
|
| 385 |
+
<footer class="footer">
|
| 386 |
+
<div class="container">
|
| 387 |
+
<div class="footer-content">
|
| 388 |
+
<div class="footer-left">
|
| 389 |
+
<p>Built with ❤️ by <strong>Inderjeet</strong></p>
|
| 390 |
+
</div>
|
| 391 |
+
<div class="footer-right">
|
| 392 |
+
<a href="{{ github_url }}" target="_blank"><i class="fab fa-github"></i></a>
|
| 393 |
+
<a href="{{ dagshub_url }}" target="_blank"><i class="fas fa-flask"></i></a>
|
| 394 |
+
</div>
|
| 395 |
+
</div>
|
| 396 |
+
</div>
|
| 397 |
+
</footer>
|
| 398 |
+
|
| 399 |
+
<script src="/static/js/main.js"></script>
|
| 400 |
+
<script>
|
| 401 |
+
// Sample data for quick fill
|
| 402 |
+
const samples = {
|
| 403 |
+
legitimate: {
|
| 404 |
+
having_IP_Address: 1, URL_Length: 1, Shortining_Service: 1, having_At_Symbol: 1,
|
| 405 |
+
double_slash_redirecting: 1, Prefix_Suffix: 1, having_Sub_Domain: 1, SSLfinal_State: 1,
|
| 406 |
+
Domain_registeration_length: 1, Favicon: 1, port: 1, HTTPS_token: 1, Request_URL: 1,
|
| 407 |
+
URL_of_Anchor: 1, Links_in_tags: 1, SFH: 1, Submitting_to_email: 1, Abnormal_URL: 1,
|
| 408 |
+
Redirect: 0, on_mouseover: 1, RightClick: 1, popUpWidnow: 1, Iframe: 1, age_of_domain: 1,
|
| 409 |
+
DNSRecord: 1, web_traffic: 1, Page_Rank: 1, Google_Index: 1, Links_pointing_to_page: 1,
|
| 410 |
+
Statistical_report: 1
|
| 411 |
+
},
|
| 412 |
+
phishing: {
|
| 413 |
+
having_IP_Address: -1, URL_Length: -1, Shortining_Service: -1, having_At_Symbol: -1,
|
| 414 |
+
double_slash_redirecting: -1, Prefix_Suffix: -1, having_Sub_Domain: -1, SSLfinal_State: -1,
|
| 415 |
+
Domain_registeration_length: -1, Favicon: -1, port: -1, HTTPS_token: -1, Request_URL: -1,
|
| 416 |
+
URL_of_Anchor: -1, Links_in_tags: -1, SFH: -1, Submitting_to_email: -1, Abnormal_URL: -1,
|
| 417 |
+
Redirect: 0, on_mouseover: -1, RightClick: -1, popUpWidnow: -1, Iframe: -1, age_of_domain: -1,
|
| 418 |
+
DNSRecord: -1, web_traffic: -1, Page_Rank: -1, Google_Index: -1, Links_pointing_to_page: -1,
|
| 419 |
+
Statistical_report: -1
|
| 420 |
+
}
|
| 421 |
+
};
|
| 422 |
+
|
| 423 |
+
function fillSample(type) {
|
| 424 |
+
const data = samples[type];
|
| 425 |
+
for (const [name, value] of Object.entries(data)) {
|
| 426 |
+
const radio = document.querySelector(`input[name="${name}"][value="${value}"]`);
|
| 427 |
+
if (radio) radio.checked = true;
|
| 428 |
+
}
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
function clearForm() {
|
| 432 |
+
document.querySelectorAll('input[value="0"]').forEach(radio => radio.checked = true);
|
| 433 |
+
}
|
| 434 |
+
</script>
|
| 435 |
+
</body>
|
| 436 |
+
</html>
|
test.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import os
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import io
|
| 5 |
+
|
| 6 |
+
BASE_URL = "http://127.0.0.1:8000"
|
| 7 |
+
|
| 8 |
+
def print_status(component, status, message=""):
|
| 9 |
+
symbol = "✅" if status else "❌"
|
| 10 |
+
print(f"{symbol} {component}: {message}")
|
| 11 |
+
|
| 12 |
+
def test_health():
|
| 13 |
+
try:
|
| 14 |
+
response = requests.get(f"{BASE_URL}/")
|
| 15 |
+
if response.status_code == 200:
|
| 16 |
+
print_status("Health Check", True, "Server is reachable")
|
| 17 |
+
else:
|
| 18 |
+
print_status("Health Check", False, f"Status Code {response.status_code}")
|
| 19 |
+
except Exception as e:
|
| 20 |
+
print_status("Health Check", False, f"Connection Failed: {str(e)}")
|
| 21 |
+
|
| 22 |
+
def test_training():
|
| 23 |
+
print("\n[ Testing Training Endpoint ]")
|
| 24 |
+
try:
|
| 25 |
+
# Note: This might take a while if actual training happens
|
| 26 |
+
response = requests.post(f"{BASE_URL}/api/train")
|
| 27 |
+
if response.status_code == 200:
|
| 28 |
+
data = response.json()
|
| 29 |
+
print_status("Training", True, data.get("message", "Training started"))
|
| 30 |
+
else:
|
| 31 |
+
print_status("Training", False, f"Failed with {response.status_code}: {response.text}")
|
| 32 |
+
except Exception as e:
|
| 33 |
+
print_status("Training", False, str(e))
|
| 34 |
+
|
| 35 |
+
def test_single_prediction():
|
| 36 |
+
print("\n[ Testing Single Prediction ]")
|
| 37 |
+
# Sample legitimate-looking data (mostly 1s or 0s depending on feature encoding)
|
| 38 |
+
data = {
|
| 39 |
+
"having_IP_Address": 1,
|
| 40 |
+
"URL_Length": 1,
|
| 41 |
+
"Shortining_Service": 1,
|
| 42 |
+
"having_At_Symbol": 1,
|
| 43 |
+
"double_slash_redirecting": 1,
|
| 44 |
+
"Prefix_Suffix": 1,
|
| 45 |
+
"having_Sub_Domain": 1,
|
| 46 |
+
"SSLfinal_State": 1,
|
| 47 |
+
"Domain_registeration_length": 1,
|
| 48 |
+
"Favicon": 1,
|
| 49 |
+
"port": 1,
|
| 50 |
+
"HTTPS_token": 1,
|
| 51 |
+
"Request_URL": 1,
|
| 52 |
+
"URL_of_Anchor": 1,
|
| 53 |
+
"Links_in_tags": 1,
|
| 54 |
+
"SFH": 1,
|
| 55 |
+
"Submitting_to_email": 1,
|
| 56 |
+
"Abnormal_URL": 1,
|
| 57 |
+
"Redirect": 1,
|
| 58 |
+
"on_mouseover": 1,
|
| 59 |
+
"RightClick": 1,
|
| 60 |
+
"popUpWidnow": 1,
|
| 61 |
+
"Iframe": 1,
|
| 62 |
+
"age_of_domain": 1,
|
| 63 |
+
"DNSRecord": 1,
|
| 64 |
+
"web_traffic": 1,
|
| 65 |
+
"Page_Rank": 1,
|
| 66 |
+
"Google_Index": 1,
|
| 67 |
+
"Links_pointing_to_page": 1,
|
| 68 |
+
"Statistical_report": 1
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
try:
|
| 72 |
+
response = requests.post(f"{BASE_URL}/api/predict/single", data=data)
|
| 73 |
+
if response.status_code == 200:
|
| 74 |
+
result = response.json()
|
| 75 |
+
print_status("Single Predict", True, f"Prediction: {result.get('prediction')} (Safe: {result.get('is_safe')})")
|
| 76 |
+
else:
|
| 77 |
+
print_status("Single Predict", False, f"Status {response.status_code}: {response.text}")
|
| 78 |
+
except Exception as e:
|
| 79 |
+
print_status("Single Predict", False, str(e))
|
| 80 |
+
|
| 81 |
+
def test_batch_prediction():
|
| 82 |
+
print("\n[ Testing Batch Prediction ]")
|
| 83 |
+
# Create dummy CSV
|
| 84 |
+
df = pd.DataFrame([{
|
| 85 |
+
"having_IP_Address": 1, "URL_Length": 1, "Shortining_Service": 1, "having_At_Symbol": 1,
|
| 86 |
+
"double_slash_redirecting": 1, "Prefix_Suffix": 1, "having_Sub_Domain": 1, "SSLfinal_State": 1,
|
| 87 |
+
"Domain_registeration_length": 1, "Favicon": 1, "port": 1, "HTTPS_token": 1, "Request_URL": 1,
|
| 88 |
+
"URL_of_Anchor": 1, "Links_in_tags": 1, "SFH": 1, "Submitting_to_email": 1, "Abnormal_URL": 1,
|
| 89 |
+
"Redirect": 1, "on_mouseover": 1, "RightClick": 1, "popUpWidnow": 1, "Iframe": 1, "age_of_domain": 1,
|
| 90 |
+
"DNSRecord": 1, "web_traffic": 1, "Page_Rank": 1, "Google_Index": 1, "Links_pointing_to_page": 1,
|
| 91 |
+
"Statistical_report": 1
|
| 92 |
+
}] * 5) # 5 rows
|
| 93 |
+
|
| 94 |
+
csv_buffer = io.StringIO()
|
| 95 |
+
df.to_csv(csv_buffer, index=False)
|
| 96 |
+
csv_buffer.seek(0)
|
| 97 |
+
|
| 98 |
+
files = {'file': ('test_batch.csv', csv_buffer.getvalue(), 'text/csv')}
|
| 99 |
+
|
| 100 |
+
try:
|
| 101 |
+
response = requests.post(f"{BASE_URL}/predict", files=files)
|
| 102 |
+
if response.status_code == 200:
|
| 103 |
+
# It returns a template, so checking text length or specific marker
|
| 104 |
+
if "Prediction Results" in response.text or "table" in response.text:
|
| 105 |
+
print_status("Batch Predict", True, "Received HTML response with results")
|
| 106 |
+
else:
|
| 107 |
+
print_status("Batch Predict", True, f"Response received (Length: {len(response.text)})")
|
| 108 |
+
else:
|
| 109 |
+
print_status("Batch Predict", False, f"Status {response.status_code}")
|
| 110 |
+
except Exception as e:
|
| 111 |
+
print_status("Batch Predict", False, str(e))
|
| 112 |
+
|
| 113 |
+
if __name__ == "__main__":
|
| 114 |
+
print("🚀 Starting Unified Verification...")
|
| 115 |
+
test_health()
|
| 116 |
+
test_training()
|
| 117 |
+
test_single_prediction()
|
| 118 |
+
test_batch_prediction()
|
| 119 |
+
print("\n✨ Verification Complete")
|