This commit is contained in:
2025-05-21 19:12:07 +05:30
parent 4d9678a0ea
commit 6f340990e9
4 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import axios from "axios";
import FormData from "form-data";
import { Express } from "express";
export interface ExtractedData {
name?: string;
memberId?: string;
dob?: string;
[key: string]: any; // In case your extraction returns additional dynamic fields
}
export default async function forwardToPythonService(
file: Express.Multer.File
): Promise<ExtractedData> {
const form = new FormData();
form.append("pdf", file.buffer, {
filename: file.originalname,
contentType: file.mimetype,
});
const response = await axios.post<ExtractedData>(
"http://localhost:5001/extract",
form,
{
headers: form.getHeaders(),
}
);
return response.data;
}