Files
OCR/frontend/src/app/ocr.service.ts

27 lines
825 B
TypeScript

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class OcrService {
private apiUrl = 'http://localhost:8000/api/ocr';
constructor(private http: HttpClient) { }
extractText(file: File): Observable<any> {
const formData = new FormData();
formData.append('file', file);
return this.http.post(`${this.apiUrl}/extract`, formData);
}
extractWithAI(text: string, filePath: string | null, modelType: string): Observable<any> {
return this.http.post(`http://localhost:8000/api/extract/ai`, { text, file_path: filePath, model_type: modelType });
}
saveDocument(data: any): Observable<any> {
return this.http.post(`http://localhost:8000/api/documents/save`, data);
}
}