Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,12 +3,7 @@ import tsadropboxretrieval
|
|
| 3 |
import pdftotext
|
| 4 |
import requests
|
| 5 |
app = Flask(__name__)
|
| 6 |
-
# API_KEY = "adrpdftotext" # Replace with your actual API key
|
| 7 |
|
| 8 |
-
# def check_api_key():
|
| 9 |
-
# api_key = request.headers.get("x-api-key")
|
| 10 |
-
# if api_key != API_KEY:
|
| 11 |
-
# abort(403) # Forbidden if API key is missing or incorrect
|
| 12 |
@app.route("/",methods=["GET", "POST"])
|
| 13 |
def thismain():
|
| 14 |
print('ayhaga')
|
|
@@ -21,31 +16,34 @@ def process():
|
|
| 21 |
|
| 22 |
print('In process [Try]')
|
| 23 |
data = request.form
|
| 24 |
-
# data = json.loads(request.data)
|
| 25 |
-
print('here',data)
|
| 26 |
-
# data = request.get_json() # Use get_json() to parse JSON data
|
| 27 |
-
# print('Received data:', data)
|
| 28 |
# Extracting values
|
| 29 |
filePath = data.get('filePath')
|
| 30 |
groupName = data.get('groupName')
|
| 31 |
|
| 32 |
-
|
| 33 |
-
# dbxTeam = tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 34 |
-
# print('3')
|
| 35 |
-
# md, res = dbxTeam.files_download(path=filePath)
|
| 36 |
-
# pdf_data = res.content
|
| 37 |
-
print('4')
|
| 38 |
-
|
| 39 |
-
|
| 40 |
pdftext = pdftotext.texts_from_pdf(filePath,groupName)
|
| 41 |
-
print('5')
|
| 42 |
-
|
| 43 |
return jsonify(pdftext)
|
| 44 |
|
| 45 |
except Exception as e:
|
| 46 |
print(f"Error: {e}")
|
| 47 |
return jsonify({"error": str(e)}), 500
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
if __name__ == '__main__':
|
| 50 |
app.run(host='0.0.0.0', port=7860)
|
| 51 |
# from flask import Flask, request, jsonify
|
|
|
|
| 3 |
import pdftotext
|
| 4 |
import requests
|
| 5 |
app = Flask(__name__)
|
|
|
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
@app.route("/",methods=["GET", "POST"])
|
| 8 |
def thismain():
|
| 9 |
print('ayhaga')
|
|
|
|
| 16 |
|
| 17 |
print('In process [Try]')
|
| 18 |
data = request.form
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Extracting values
|
| 20 |
filePath = data.get('filePath')
|
| 21 |
groupName = data.get('groupName')
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
pdftext = pdftotext.texts_from_pdf(filePath,groupName)
|
|
|
|
|
|
|
| 24 |
return jsonify(pdftext)
|
| 25 |
|
| 26 |
except Exception as e:
|
| 27 |
print(f"Error: {e}")
|
| 28 |
return jsonify({"error": str(e)}), 500
|
| 29 |
|
| 30 |
+
|
| 31 |
+
@app.route("/apiMC",methods=["GET", "POST"])
|
| 32 |
+
def thismain():
|
| 33 |
+
try:
|
| 34 |
+
print('In process [Try]')
|
| 35 |
+
data = request.form
|
| 36 |
+
print('here',data)
|
| 37 |
+
# Extracting values
|
| 38 |
+
allapi = data.get('allapi')
|
| 39 |
+
print(allapi)
|
| 40 |
+
return jsonify('received')
|
| 41 |
+
|
| 42 |
+
except error:
|
| 43 |
+
print(f"Error: {e}")
|
| 44 |
+
return jsonify({"error": str(e)}), 500
|
| 45 |
+
|
| 46 |
+
|
| 47 |
if __name__ == '__main__':
|
| 48 |
app.run(host='0.0.0.0', port=7860)
|
| 49 |
# from flask import Flask, request, jsonify
|