File size: 2,691 Bytes
f4bee9e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
๏ปฟ"""
๐ข ENTERPRISE PLATFORM - SIMPLIFIED TEST API
Starts just the essentials to verify everything works.
"""
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
from fastapi import FastAPI
import uvicorn
import torch
import numpy as np
from datetime import datetime
print("\n" + "="*80)
print("๐ข ENTERPRISE ADVERSARIAL ML SECURITY PLATFORM")
print("Simplified Test API")
print("="*80)
# Create the FastAPI app
app = FastAPI(
title="Enterprise Adversarial ML Security Platform",
description="Simplified test version",
version="4.0.0-test"
)
@app.get("/")
async def root():
"""Root endpoint"""
return {
"service": "enterprise-adversarial-ml-security",
"version": "4.0.0-test",
"status": "running",
"timestamp": datetime.now().isoformat()
}
@app.get("/health")
async def health():
"""Health check endpoint"""
return {
"status": "healthy",
"components": {
"api": True,
"pytorch": torch.__version__,
"numpy": np.__version__
}
}
@app.get("/test/firewall")
async def test_firewall():
"""Test firewall import"""
try:
from firewall.detector import ModelFirewall
firewall = ModelFirewall()
return {
"status": "success",
"component": "firewall",
"message": "ModelFirewall loaded successfully"
}
except Exception as e:
return {
"status": "error",
"component": "firewall",
"error": str(e)
}
@app.get("/test/intelligence")
async def test_intelligence():
"""Test intelligence import"""
try:
from intelligence.telemetry.attack_monitor import AttackTelemetry
telemetry = AttackTelemetry()
return {
"status": "success",
"component": "intelligence",
"message": "AttackTelemetry loaded successfully"
}
except Exception as e:
return {
"status": "error",
"component": "intelligence",
"error": str(e)
}
if __name__ == "__main__":
print("๐ Starting simplified enterprise API...")
print("๐ก Available at: http://localhost:8001")
print("๐ Documentation: http://localhost:8001/docs")
print("๐ Press CTRL+C to stop\n")
try:
uvicorn.run(
app,
host="0.0.0.0",
port=8001, # Use port 8001 to avoid conflicts
log_level="info"
)
except Exception as e:
print(f"โ Failed to start API: {e}")
sys.exit(1)
|