Camelot reading
This commit is contained in:
@ -5,6 +5,7 @@ from flask import Flask, request
|
||||
import contabilidad.pdf as pdf
|
||||
import contabilidad.passwords as passwords
|
||||
import contabilidad.log as log
|
||||
import contabilidad.text_handler as th
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
@ -18,17 +19,21 @@ def pdf_parse():
|
||||
data['files'] = [data['files']]
|
||||
password_file = '/app/config/.passwords.yml'
|
||||
pwds = passwords.get_passwords(password_file)
|
||||
texts = []
|
||||
output = []
|
||||
for file in data['files']:
|
||||
filename = os.path.realpath(os.path.join('/app/data', file['filename']))
|
||||
texts = []
|
||||
for p in pwds:
|
||||
obj = pdf.get_data(filename, p)
|
||||
print(obj)
|
||||
obj = pdf.get_text(filename, p)
|
||||
if obj is None:
|
||||
continue
|
||||
print(obj)
|
||||
texts.append(json.dumps(obj))
|
||||
return json.dumps(texts)
|
||||
text = th.text_cleanup(obj, file['filename'])
|
||||
texts.append(text)
|
||||
output.append({'filename': file['filename'], 'text': texts})
|
||||
return json.dumps(output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0')
|
||||
app.run(host='0.0.0.0', debug=True)
|
||||
|
Reference in New Issue
Block a user