INNER CODE UNIT · Python

_format_upload_result

Nuclear-Marmalade/dataforge · forge/dashboard/app.py:551

def _format_upload_result(result: dict) -> HTMLResponse:
    """Format import result as HTML."""
    imported = result.get("imported", 0)
    total = result.get("total_rows", 0)
    mapping = result.get("column_mapping", {})
    mapped_cols = ", ".join(f"{k} -> {v}" for k, v in list(mapping.items())[:6])
    return HTMLResponse(
        f'<div class="forge-card text-center py-6 space-y-3">'
        f'<p class="text-3xl font-bold text-amber-400">{imported:,}</p>'
        f'<p class="text-gray-300">records imported from {total:,} rows</p>'
        f'<p class="text-sm text-gray-500">Columns mapped: {_esc(mapped_cols)}</p>'
        f'<a href="/enrich" class="forge-btn inline-block mt-4">Start Enrichment</a></div>'
    )


@app.post("/api/upload", response_class=HTMLResponse)
async def api_upload(file: UploadFile = File(...)):
    """Handle CSV file upload.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…