Update 'Business_cards/Business_cards.py'
Этот коммит содержится в:
@@ -64,13 +64,13 @@ def card():
|
|||||||
return render_template('card.html')
|
return render_template('card.html')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/upload_BusinessCards', methods=["POST"])
|
@app.route('/upload_BusinessCards', methods=["POST"])
|
||||||
# @app.route('/multiplecards', methods=["POST"])
|
# @app.route('/multiplecards', methods=["POST"])
|
||||||
def multiplecards():
|
def multiplecards():
|
||||||
# print('################## multiple card detection #######################')
|
# print('################## multiple card detection #######################')
|
||||||
# print(Dataset)
|
# print(Dataset)
|
||||||
datalist=[]
|
datalist=[]
|
||||||
|
zlist=[]
|
||||||
Dataset = request.get_json()
|
Dataset = request.get_json()
|
||||||
# print(data)
|
# print(data)
|
||||||
#datalist.append(Dataset)
|
#datalist.append(Dataset)
|
||||||
@@ -161,7 +161,7 @@ def multiplecards():
|
|||||||
import pytesseract as tess
|
import pytesseract as tess
|
||||||
from PIL import Image
|
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")
|
pdf = tess.image_to_pdf_or_hocr(fname, extension="pdf")
|
||||||
with open("demo.pdf", "w+b", ) as f:
|
with open("demo.pdf", "w+b", ) as f:
|
||||||
f.write(pdf)
|
f.write(pdf)
|
||||||
@@ -406,21 +406,18 @@ def multiplecards():
|
|||||||
verticaltext = x
|
verticaltext = x
|
||||||
htext = x
|
htext = x
|
||||||
# print('------------------------------------------------')
|
# print('------------------------------------------------')
|
||||||
print(
|
#print('############################################################# this is verticaltext #################################################################')
|
||||||
'############################################################# this is verticaltext #################################################################')
|
# print(verticaltext)
|
||||||
print(verticaltext)
|
|
||||||
htext = htext.replace('\n', ' ')
|
htext = htext.replace('\n', ' ')
|
||||||
print(
|
# print('############################################################# this is htext #############################################################')
|
||||||
'############################################################# this is htext #############################################################')
|
#print(htext)
|
||||||
print(htext)
|
|
||||||
y = x.replace('\n', ',')
|
y = x.replace('\n', ',')
|
||||||
y = y.replace(' ', ' ')
|
y = y.replace(' ', ' ')
|
||||||
# y = y.replace(".", " .")
|
# y = y.replace(".", " .")
|
||||||
horizontaltext = y
|
horizontaltext = y
|
||||||
# print('------------------------------------------------')
|
# print('------------------------------------------------')
|
||||||
print(
|
#print('############################################################# this is horizontaltext #############################################################')
|
||||||
'############################################################# this is horizontaltext #############################################################')
|
#print(horizontaltext)
|
||||||
print(horizontaltext)
|
|
||||||
|
|
||||||
textfile = open("test123456.txt", "w")
|
textfile = open("test123456.txt", "w")
|
||||||
a = textfile.write(verticaltext)
|
a = textfile.write(verticaltext)
|
||||||
@@ -960,7 +957,7 @@ def multiplecards():
|
|||||||
|
|
||||||
# print(addrespinlst)
|
# print(addrespinlst)
|
||||||
import pgeocode
|
import pgeocode
|
||||||
print(line12)
|
#print(line12)
|
||||||
import re
|
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)
|
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:
|
for i in matche1:
|
||||||
@@ -1062,51 +1059,58 @@ def multiplecards():
|
|||||||
z.update(y)
|
z.update(y)
|
||||||
# the result is a JSON string:
|
# the result is a JSON string:
|
||||||
# print(json.dumps(z))
|
# print(json.dumps(z))
|
||||||
zlist=[]
|
|
||||||
zlist.append(z)
|
zlist.append(z)
|
||||||
#############################################creating csv#####################################
|
#############################################creating csv#####################################
|
||||||
print(final)
|
#print(final)
|
||||||
print(imagelist)
|
#print(imagelist)
|
||||||
final.append('image--' + str(imagelist))
|
#final.append('image--' + str(imagelist))
|
||||||
import requests
|
# import requests
|
||||||
import json
|
# 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(payload1)
|
# # url = "https://anwi.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create/list" #dev
|
||||||
print(response.text)
|
# url = "https://qa.bizgaze.com/apis/v4/bizgaze/integrations/businesscards/create/list" #testing
|
||||||
import os
|
# # url = "https://test.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create" # test
|
||||||
if 'BusinessCards Created Successfully' in response.text:
|
# # url='http://localhost:3088/apis/v4/bizgaze/integrations/businesscards/create'
|
||||||
print('present')
|
# # url = 'https://c01.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create' # C01
|
||||||
os.remove(found)
|
# payload1 = json.dumps(zlist)
|
||||||
else:
|
# # print('--------------------------------------------------------------------------')
|
||||||
print('not present')
|
# #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')
|
# 'Content-Type': 'application/json'
|
||||||
print(data)
|
# }
|
||||||
|
# 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 render_template('index.html')
|
||||||
|
|
||||||
|
|
||||||
return response.text
|
#return response.text
|
||||||
# return 'done'
|
#return z
|
||||||
|
return zlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user