Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,6 +137,22 @@ async def mobile_process_receipts(background_tasks: BackgroundTasks, sheeturl: s
|
|
| 137 |
uuid = str(uuid4())
|
| 138 |
timestamp = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
| 139 |
sheetID = sheeturl.split('/')[-2]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
message = "영수기 AI가 데이터 분석 중입니다. 잠시만 기다려주세요."
|
| 142 |
data = [timestamp, uuid, message]
|
|
|
|
| 137 |
uuid = str(uuid4())
|
| 138 |
timestamp = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
| 139 |
sheetID = sheeturl.split('/')[-2]
|
| 140 |
+
base64_str = base64.b64encode(image_contents).decode('utf-8')
|
| 141 |
+
|
| 142 |
+
checkPhoto = {
|
| 143 |
+
'sheetID': sheetID,
|
| 144 |
+
'mode': "check",
|
| 145 |
+
'photo': base64_str,
|
| 146 |
+
'mimeType': image.content_type,
|
| 147 |
+
'fileName': 'test.png'
|
| 148 |
+
}
|
| 149 |
+
async with httpx.AsyncClient(timeout=300, follow_redirects=True) as client:
|
| 150 |
+
response = await client.post(appsScriptsURL, json=checkPhoto)
|
| 151 |
+
if response.status_code != 200:
|
| 152 |
+
logging.error(f"Unexpected response from Google Apps Script API: {response.status_code} - {response.text}")
|
| 153 |
+
raise HTTPException(status_code=500, detail="Error from external API.")
|
| 154 |
+
if response.json()['status'] == 'invalid':
|
| 155 |
+
return {"message": "Invalid photo."}
|
| 156 |
|
| 157 |
message = "영수기 AI가 데이터 분석 중입니다. 잠시만 기다려주세요."
|
| 158 |
data = [timestamp, uuid, message]
|