Omkar008's picture
Create app.py
df6525b verified
raw
history blame
824 Bytes
from fastapi import FastAPI, HTTPException,Query
import json
app = FastAPI()
@app.post("/process-document-base64")
async def process_document_base64(request_data: dict):
# If receiving base64 string directly
payload = {
"skipHumanReview": True,
"rawDocument": {
"mimeType": "application/pdf",
"content": request_data['base64_content']
}
}
access_token = get_access_token()
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json; charset=utf-8'
}
response = requests.post(
'https://us-documentai.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/us/processors/YOUR_PROCESSOR_ID:process',
headers=headers,
json=payload
)
return response.json()