Files
warehouse13/app/main.py
Mondo Diaz 7b2b49e394 Add web UI with artifact table and upload functionality
Features:
- Modern web interface with table view of all artifacts
- Display all metadata: filename, type, size, test info, tags
- Upload form with full metadata support
- Query/filter interface
- Detail modal for viewing full artifact information
- Download and delete actions
- Integrated seed data generation via UI
- Responsive design with gradient theme

Technical:
- Pure HTML/CSS/JavaScript (no frameworks)
- FastAPI serves static files
- Seed data API endpoint for easy testing
- Pagination support
- Real-time deployment mode display

The UI is now accessible at http://localhost:8000/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 16:12:32 -05:00

101 lines
2.6 KiB
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from app.api.artifacts import router as artifacts_router
from app.api.seed import router as seed_router
from app.database import init_db
from app.config import settings
import logging
import os
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
# Create FastAPI app
app = FastAPI(
title="Test Artifact Data Lake",
description="API for storing and querying test artifacts including CSV, JSON, binary files, and packet captures",
version="1.0.0",
docs_url="/docs",
redoc_url="/redoc"
)
# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(artifacts_router)
app.include_router(seed_router)
# Mount static files
static_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "static")
if os.path.exists(static_dir):
app.mount("/static", StaticFiles(directory=static_dir), name="static")
@app.on_event("startup")
async def startup_event():
"""Initialize database on startup"""
logger.info("Initializing database...")
init_db()
logger.info(f"Deployment mode: {settings.deployment_mode}")
logger.info(f"Using storage backend: {settings.storage_backend}")
logger.info("Application started successfully")
@app.get("/api")
async def api_root():
"""API root endpoint"""
return {
"message": "Test Artifact Data Lake API",
"version": "1.0.0",
"docs": "/docs",
"deployment_mode": settings.deployment_mode,
"storage_backend": settings.storage_backend
}
@app.get("/")
async def ui_root():
"""Serve the UI"""
index_path = os.path.join(static_dir, "index.html")
if os.path.exists(index_path):
return FileResponse(index_path)
else:
return {
"message": "Test Artifact Data Lake API",
"version": "1.0.0",
"docs": "/docs",
"ui": "UI not found. Serving API only.",
"deployment_mode": settings.deployment_mode,
"storage_backend": settings.storage_backend
}
@app.get("/health")
async def health_check():
"""Health check endpoint"""
return {"status": "healthy"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(
"app.main:app",
host=settings.api_host,
port=settings.api_port,
reload=True
)