expense_parser / main.py
Omkar008's picture
Update main.py
598cf2e verified
from fastapi import FastAPI, HTTPException,Query,Request,BackgroundTasks
import json
from authenticate import get_access_token,get_access_token_v1
import os
import requests
from extract_and_store_supabase import extract_structure_store_message
app = FastAPI()
@app.post("/process_uploaded_document")
async def process_document_base64(request: Request,background_tasks: BackgroundTasks):
request_data = await request.json()
# print(request_data.get('filename'))
file_name_ = request_data.get('filename').split('/')[-1]
file_name = request_data.get('filename').split('/')[-5:]
file_name_path = '/'.join(file_name)
print("printing filename")
print(file_name)
user_id = request_data.get('user_id')
email = request_data.get('email')
# attachment_extension = request_data.get('attachment_extension')
print(user_id)
await extract_structure_store_message(file_name_,file_name_path,user_id,email)
# background_tasks.add_task(extract_structure_store_message,file_name,user_id)
return {"status":'Processing and Updating the data to db!'}