Update 'Business_cards/Business_cards.py'
This commit is contained in:
@@ -64,13 +64,13 @@ def card():
|
||||
return render_template('card.html')
|
||||
|
||||
|
||||
|
||||
@app.route('/upload_BusinessCards', methods=["POST"])
|
||||
# @app.route('/multiplecards', methods=["POST"])
|
||||
def multiplecards():
|
||||
# print('################## multiple card detection #######################')
|
||||
# print(Dataset)
|
||||
datalist=[]
|
||||
zlist=[]
|
||||
Dataset = request.get_json()
|
||||
# print(data)
|
||||
#datalist.append(Dataset)
|
||||
@@ -161,7 +161,7 @@ def multiplecards():
|
||||
import pytesseract as tess
|
||||
from PIL import Image
|
||||
|
||||
tess.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
|
||||
tess.pytesseract.tesseract_cmd = r"C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe"
|
||||
pdf = tess.image_to_pdf_or_hocr(fname, extension="pdf")
|
||||
with open("demo.pdf", "w+b", ) as f:
|
||||
f.write(pdf)
|
||||
@@ -406,21 +406,18 @@ def multiplecards():
|
||||
verticaltext = x
|
||||
htext = x
|
||||
# print('------------------------------------------------')
|
||||
print(
|
||||
'############################################################# this is verticaltext #################################################################')
|
||||
print(verticaltext)
|
||||
#print('############################################################# this is verticaltext #################################################################')
|
||||
# print(verticaltext)
|
||||
htext = htext.replace('\n', ' ')
|
||||
print(
|
||||
'############################################################# this is htext #############################################################')
|
||||
print(htext)
|
||||
# print('############################################################# this is htext #############################################################')
|
||||
#print(htext)
|
||||
y = x.replace('\n', ',')
|
||||
y = y.replace(' ', ' ')
|
||||
# y = y.replace(".", " .")
|
||||
horizontaltext = y
|
||||
# print('------------------------------------------------')
|
||||
print(
|
||||
'############################################################# this is horizontaltext #############################################################')
|
||||
print(horizontaltext)
|
||||
#print('############################################################# this is horizontaltext #############################################################')
|
||||
#print(horizontaltext)
|
||||
|
||||
textfile = open("test123456.txt", "w")
|
||||
a = textfile.write(verticaltext)
|
||||
@@ -960,7 +957,7 @@ def multiplecards():
|
||||
|
||||
# print(addrespinlst)
|
||||
import pgeocode
|
||||
print(line12)
|
||||
#print(line12)
|
||||
import re
|
||||
matche1 = re.findall(r'-\d{6}|\b\d{6}\b|\b\d{3} \d{3}\b|-\d{3} \d{3}|\b\d{3} \d{3}\b', line12)
|
||||
for i in matche1:
|
||||
@@ -1062,51 +1059,58 @@ def multiplecards():
|
||||
z.update(y)
|
||||
# the result is a JSON string:
|
||||
# print(json.dumps(z))
|
||||
zlist=[]
|
||||
|
||||
zlist.append(z)
|
||||
#############################################creating csv#####################################
|
||||
print(final)
|
||||
print(imagelist)
|
||||
final.append('image--' + str(imagelist))
|
||||
import requests
|
||||
import json
|
||||
url = "https://anwi.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create/list" #dev
|
||||
# url = "https://qa.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create" #testing
|
||||
# url = "https://test.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create" # test
|
||||
# url='http://localhost:3088/apis/v4/bizgaze/integrations/businesscards/create'
|
||||
# url = 'https://c01.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create' # C01
|
||||
payload1 = json.dumps(zlist)
|
||||
# print('--------------------------------------------------------------------------')
|
||||
#print(payload1)
|
||||
headers = {
|
||||
#'Authorization': 'stat 1a936137490040c997928f485e3cdd7a', #dev
|
||||
'Authorization': 'stat 16516391d0074f4c8a15ea16fb49470b',#testing
|
||||
# 'Authorization': 'stat 08e55fcfbaa940c8ab8145a074c444d1',
|
||||
# 'Authorization': 'stat f7cdb402e01e44e5842878653946168f', # c01
|
||||
# 'Authorization': 'Stat c3e11b2fcbfe455b86a1fe6efde02a69',#demo
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload1)
|
||||
# print("##############################################################")
|
||||
#print(final)
|
||||
#print(imagelist)
|
||||
#final.append('image--' + str(imagelist))
|
||||
# import requests
|
||||
# import json
|
||||
|
||||
#print(payload1)
|
||||
print(response.text)
|
||||
import os
|
||||
if 'BusinessCards Created Successfully' in response.text:
|
||||
print('present')
|
||||
os.remove(found)
|
||||
else:
|
||||
print('not present')
|
||||
# # url = "https://anwi.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create/list" #dev
|
||||
# url = "https://qa.bizgaze.com/apis/v4/bizgaze/integrations/businesscards/create/list" #testing
|
||||
# # url = "https://test.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create" # test
|
||||
# # url='http://localhost:3088/apis/v4/bizgaze/integrations/businesscards/create'
|
||||
# # url = 'https://c01.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create' # C01
|
||||
# payload1 = json.dumps(zlist)
|
||||
# # print('--------------------------------------------------------------------------')
|
||||
# #print(payload1)
|
||||
# headers = {
|
||||
# #'Authorization': 'stat 1a936137490040c997928f485e3cdd7a', #dev
|
||||
# # 'Authorization': 'stat 16516391d0074f4c8a15ea16fb49470b',#testing
|
||||
# # 'Authorization': 'stat 08e55fcfbaa940c8ab8145a074c444d1',
|
||||
# # 'Authorization': 'stat f7cdb402e01e44e5842878653946168f', # c01
|
||||
# #'Authorization': 'Stat c3e11b2fcbfe455b86a1fe6efde02a69',#demo
|
||||
# 'Authorization':'Stat e5bc6ad08f2c42feb5f98a2a521d00af',
|
||||
|
||||
df1.to_json('visitingcard.json')
|
||||
data = df1.to_json('visiting.json', orient='records')
|
||||
print(data)
|
||||
|
||||
# 'Content-Type': 'application/json'
|
||||
# }
|
||||
# response = requests.request("POST", url, headers=headers, data=payload1)
|
||||
# # print("##############################################################")
|
||||
|
||||
# print(payload1)
|
||||
# #print(zlist)
|
||||
# # import os
|
||||
# # if 'BusinessCards Created Successfully' in response.text:
|
||||
# # print('present')
|
||||
# # os.remove(found)
|
||||
# # else:
|
||||
# # print('not present')
|
||||
|
||||
# df1.to_json('visitingcard.json')
|
||||
# data = df1.to_json('visiting.json', orient='records')
|
||||
# print(data)
|
||||
|
||||
#return render_template('index.html')
|
||||
|
||||
|
||||
return response.text
|
||||
# return 'done'
|
||||
#return response.text
|
||||
#return z
|
||||
return zlist
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user