m8chaa commited on
Commit
0d70c72
·
verified ·
1 Parent(s): 1921322

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -184,7 +184,7 @@ async def background_worker(sheeturl, image_contents, filename, content_type, ap
184
 
185
  # receive a sheetID and an image as multipart form data
186
  @app.post('/mobile-process-receipts')
187
- async def mobile_process_receipts(background_tasks: BackgroundTasks, sheeturl: str = Form(...), image: UploadFile = File(...)):
188
  image_contents = await image.read()
189
  uuid = str(uuid4())
190
  timestamp = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
@@ -341,22 +341,22 @@ async def cutting_image(masked_image, image_contents, cut_images, s3_orginal_url
341
  cut_images.append(base64_str)
342
 
343
 
344
- @app.post('/test')
345
- async def mobile_process_receipts(background_tasks: BackgroundTasks, sheeturl: str = Form(...), user_ref: str = Form(...), image: UploadFile = File(...)):
346
- image_contents = await image.read()
347
- uuid = str(uuid4())
348
- timestamp = str(datetime.now().strftime("%Y-%m-%d-%H-%M-%S"))
349
- message = "영수기가 데이터 분석 중입니다. 잠시만 기다려주세요."
350
- data = [timestamp, uuid, message]
351
- body = {
352
- "sheetID": sheeturl.split('/')[-2],
353
- "data": data,
354
- "mode": "alert-user"
355
- }
356
- async with httpx.AsyncClient(follow_redirects=True) as client:
357
- response = await client.post(appsScriptsURL, json=body)
358
- if response.status_code != 200:
359
- logging.error(f"Unexpected response from Google Apps Script API: {response.status_code} - {response.text}")
360
- raise HTTPException(status_code=500, detail="Error from external API.")
361
- background_tasks.add_task(background_worker, sheeturl, image_contents, image.filename, image.content_type, appsScriptsURL)
362
- return {"message": "Image processing completed."}
 
184
 
185
  # receive a sheetID and an image as multipart form data
186
  @app.post('/mobile-process-receipts')
187
+ async def mobile_process_receipts(background_tasks: BackgroundTasks, sheeturl: str = Form(...), user_ref: str = Form(...), image: UploadFile = File(...)):
188
  image_contents = await image.read()
189
  uuid = str(uuid4())
190
  timestamp = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
 
341
  cut_images.append(base64_str)
342
 
343
 
344
+ # @app.post('/test')
345
+ # async def mobile_process_receipts(background_tasks: BackgroundTasks, sheeturl: str = Form(...), user_ref: str = Form(...), image: UploadFile = File(...)):
346
+ # image_contents = await image.read()
347
+ # uuid = str(uuid4())
348
+ # timestamp = str(datetime.now().strftime("%Y-%m-%d-%H-%M-%S"))
349
+ # message = "영수기가 데이터 분석 중입니다. 잠시만 기다려주세요."
350
+ # data = [timestamp, uuid, message]
351
+ # body = {
352
+ # "sheetID": sheeturl.split('/')[-2],
353
+ # "data": data,
354
+ # "mode": "alert-user"
355
+ # }
356
+ # async with httpx.AsyncClient(follow_redirects=True) as client:
357
+ # response = await client.post(appsScriptsURL, json=body)
358
+ # if response.status_code != 200:
359
+ # logging.error(f"Unexpected response from Google Apps Script API: {response.status_code} - {response.text}")
360
+ # raise HTTPException(status_code=500, detail="Error from external API.")
361
+ # background_tasks.add_task(background_worker, sheeturl, image_contents, image.filename, image.content_type, appsScriptsURL)
362
+ # return {"message": "Image processing completed."}