Spaces:
Sleeping
Sleeping
from fastapi import FastAPI, HTTPException,Query | |
import json | |
app = FastAPI() | |
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() |