mirror of
https://github.com/bcomsugi/dasaproject.git
synced 2026-01-10 07:12:37 +07:00
change result to dict
This commit is contained in:
parent
3ca1b27b22
commit
6521a0cd4b
31
main.py
31
main.py
@ -13,6 +13,8 @@ import pdfexcel4DNwithxlrd
|
||||
from ItemInventoryQuery import ItemInventoryQuery
|
||||
from SO_to_Inv import readSO
|
||||
import os
|
||||
from icecream import ic
|
||||
import pprint
|
||||
|
||||
# app = FastAPI()
|
||||
app = FastAPI(docs_url="/itemreceipt", redoc_url=None)
|
||||
@ -89,15 +91,38 @@ async def create_upload_file(uploaded_file: UploadFile):
|
||||
status = "OK"
|
||||
else:
|
||||
print("ERROR", status_msg)
|
||||
print(f"ret:{ret}", type(ret))
|
||||
status = "ERROR"
|
||||
msg = f"ERROR. replyfromqbxml:{ret}"
|
||||
msg = f"{status}. replyfrom qbxml:{ret}"
|
||||
else:
|
||||
print("create_upload_file->not all DN are added")
|
||||
msg = f"Error. not all DN are added. \n these items not added in the list :\n{notinthelist}"
|
||||
status = 'Error'
|
||||
# ic(notinthelist)
|
||||
# errmsg = ic(notinthelist)
|
||||
# errmsg = pprint.pprint(notinthelist)
|
||||
# errmsg = str(errmsg)
|
||||
# print(errmsg, type(errmsg))
|
||||
errmsg = json.dumps(notinthelist, indent=2, sort_keys=True)
|
||||
errmsg = json.loads(errmsg)
|
||||
|
||||
return {"info": f"file '{uploaded_file.filename}' saved at '{file_location}'", "status": status, "msg": msg}
|
||||
# print(errmsg, type(errmsg))
|
||||
print(type(errmsg))
|
||||
# msg = f"Error. not all DN are added. \n these items not added in the list :\n{notinthelist}"
|
||||
msg = f"Error. not all DN are added. \n these items not added in the list :\n{errmsg}"
|
||||
|
||||
status = 'Error'
|
||||
msgdict={}
|
||||
msgdict["info"]=f'file {uploaded_file.filename} saved at {file_location}'
|
||||
msgdict["status"]=status
|
||||
msgdict["msg"]=errmsg
|
||||
print(msgdict, type(msg))
|
||||
# jsonmsg = json.dumps(msgdict)
|
||||
# jsonmsg = json.loads(jsonmsg)
|
||||
|
||||
return msgdict
|
||||
|
||||
|
||||
return [{"info": f"file '{uploaded_file.filename}' saved at '{file_location}'", "status": status, "msg": msg}]
|
||||
return {"info": f"file '{uploaded_file.filename}' is not Excel(.xls) file or it is not Delivery Note(TCO-DN)file. please upload the correct file", "status": status}
|
||||
|
||||
@app.post('/getopenso')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user