Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,20 +13,34 @@ app = Flask(__name__)
|
|
| 13 |
@app.route('/process', methods=['POST'])
|
| 14 |
def process():
|
| 15 |
# check_api_key()
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
if __name__ == '__main__':
|
| 32 |
-
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 13 |
@app.route('/process', methods=['POST'])
|
| 14 |
def process():
|
| 15 |
# check_api_key()
|
| 16 |
+
try:
|
| 17 |
+
print('In process')
|
| 18 |
+
data = request.get_json() # Correct method to get JSON data
|
| 19 |
+
print(data)
|
| 20 |
+
|
| 21 |
+
# Ensure 'pdfpath' is included in the request
|
| 22 |
+
if 'filePath' not in data:
|
| 23 |
+
return jsonify({"error": "Missing 'pdfpath' in request data"}), 400
|
| 24 |
+
|
| 25 |
+
pdfpath = data['filePath']
|
| 26 |
+
|
| 27 |
+
dbxTeam = tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 28 |
+
md, res = dbxTeam.files_download(path=pdfpath)
|
| 29 |
+
pdf_data = res.content
|
| 30 |
+
|
| 31 |
+
# Ensure 'pdftotext.texts_from_pdf' is a valid function
|
| 32 |
+
pdftext = pdftotext.texts_from_pdf(pdf_data)
|
| 33 |
+
|
| 34 |
+
# Prepare response
|
| 35 |
+
response_data = {
|
| 36 |
+
"message": "Data received",
|
| 37 |
+
"input_data": pdftext
|
| 38 |
+
}
|
| 39 |
+
return jsonify(response_data)
|
| 40 |
+
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print(f"Error: {e}")
|
| 43 |
+
return jsonify({"error": str(e)}), 500
|
| 44 |
|
| 45 |
if __name__ == '__main__':
|
| 46 |
+
app.run(host='0.0.0.0', port=7860)
|