Marthee commited on
Commit
02af7c0
·
verified ·
1 Parent(s): a8c6dd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -4,6 +4,8 @@ import json
4
  import Find_Hyperlinking_text
5
  import requests
6
  from io import BytesIO
 
 
7
  app = Flask(__name__)
8
 
9
  @app.route("/",methods=["GET", "POST"])
@@ -18,6 +20,20 @@ BASE_URL = "https://marthee-nbslink.hf.space" # Localhost URL for testing
18
  @app.route('/view-pdf', methods=['GET'])
19
  def download_pdf():
20
  global pdf_content, pageNumTextFound
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  if pdf_content is None:
23
  return "PDF content not found.", 404
@@ -33,10 +49,10 @@ def download_pdf():
33
  @app.route('/api/process-data', methods=['POST'])
34
  def receive_pdf_data():
35
  global pdf_content, pageNumTextFound
36
-
37
  # Get PDF link and keyword from the request body
38
- pdfLink = request.form.get('pdfLink')
39
- keyword = request.form.get('keyword')
40
 
41
  if not pdfLink or not keyword:
42
  return jsonify({"error": "Both 'pdfLink' and 'keyword' must be provided."}), 400
@@ -62,6 +78,9 @@ def receive_pdf_data():
62
  except Exception as e:
63
  return jsonify({"error": str(e)}), 500
64
 
65
-
 
 
 
66
  if __name__ == '__main__':
67
  app.run(host='0.0.0.0', port=7860)
 
4
  import Find_Hyperlinking_text
5
  import requests
6
  from io import BytesIO
7
+ import urllib
8
+
9
  app = Flask(__name__)
10
 
11
  @app.route("/",methods=["GET", "POST"])
 
20
  @app.route('/view-pdf', methods=['GET'])
21
  def download_pdf():
22
  global pdf_content, pageNumTextFound
23
+ pdf_link = request.args.get('pdfLink')
24
+ keyword = request.args.get('keyword')
25
+
26
+ # Check if parameters exist
27
+ if not pdf_link or not keyword:
28
+ return "Missing required parameters.", 400
29
+
30
+ # Decode URL-encoded parameters
31
+ pdf_link = urllib.parse.unquote(pdf_link) # Decode URL encoding
32
+ keyword = json.loads(urllib.parse.unquote(keyword)) # Decode and convert back to a list
33
+
34
+ # Debugging output
35
+ print("Extracted PDF Link:", pdf_link)
36
+ print("Extracted Keywords:", keyword)
37
 
38
  if pdf_content is None:
39
  return "PDF content not found.", 404
 
49
  @app.route('/api/process-data', methods=['POST'])
50
  def receive_pdf_data():
51
  global pdf_content, pageNumTextFound
52
+ pdfLink,keyword=finddata()
53
  # Get PDF link and keyword from the request body
54
+ # pdfLink = request.form.get('pdfLink')
55
+ # keyword = request.form.get('keyword')
56
 
57
  if not pdfLink or not keyword:
58
  return jsonify({"error": "Both 'pdfLink' and 'keyword' must be provided."}), 400
 
78
  except Exception as e:
79
  return jsonify({"error": str(e)}), 500
80
 
81
+ def finddata():
82
+ pdfLink = 'https://www.dropbox.com/scl/fi/hnp4mqigb51a5kp89kgfa/00801-ARC-20-ZZ-S-A-0002.pdf?rlkey=45abeoebzqw4qwnslnei6dkd6&st=m4yrcjm2&dl=1'; # Dropbox link
83
+ keyword = ['115 INTEGRATED MRI ROOM LININGS','710 TRANSPORTATION'] ; # Example keyword
84
+ return pdfLink,keyword
85
  if __name__ == '__main__':
86
  app.run(host='0.0.0.0', port=7860)