Marthee commited on
Commit
0aea4e4
·
verified ·
1 Parent(s): f96add3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -75,8 +75,43 @@ def processrawan():
75
  except Exception as e:
76
  print(f"Error: {e}")
77
  return jsonify({"error": str(e)}), 500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  if __name__ == '__main__':
79
  app.run(host='0.0.0.0', port=7860)
 
 
80
  # from flask import Flask, request, jsonify
81
 
82
  # app = Flask(__name__)
 
75
  except Exception as e:
76
  print(f"Error: {e}")
77
  return jsonify({"error": str(e)}), 500
78
+
79
+
80
+ @app.route('/processalltext', methods=['POST'])
81
+ def process():
82
+ # check_api_key()
83
+ try:
84
+ print('In process')
85
+ data = request.get_json() # Correct method to get JSON data
86
+ print(data)
87
+
88
+ # Ensure 'pdfpath' is included in the request
89
+ if 'filePath' not in data:
90
+ return jsonify({"error": "Missing 'pdfpath' in request data"}), 400
91
+
92
+ pdfpath = data['filePath']
93
+
94
+ dbxTeam = tsadropboxretrieval.ADR_Access_DropboxTeam('user')
95
+ md, res = dbxTeam.files_download(path=pdfpath)
96
+ pdf_data = res.content
97
+
98
+ # Ensure 'pdftotext.texts_from_pdf' is a valid function
99
+ pdftext = pdftotext.texts_from_pdfAllText(pdf_data)
100
+
101
+ # Prepare response
102
+ response_data = {
103
+ "message": "Data received",
104
+ "input_data": pdftext
105
+ }
106
+ return jsonify(response_data)
107
+
108
+ except Exception as e:
109
+ print(f"Error: {e}")
110
+ return jsonify({"error": str(e)}), 500
111
  if __name__ == '__main__':
112
  app.run(host='0.0.0.0', port=7860)
113
+
114
+
115
  # from flask import Flask, request, jsonify
116
 
117
  # app = Flask(__name__)