setup1
This commit is contained in:
30
apps/Backend/src/services/pythonClient.ts
Normal file
30
apps/Backend/src/services/pythonClient.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user