Marthee commited on
Commit
19c04f7
·
verified ·
1 Parent(s): a106947

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,12 +1,16 @@
1
  from flask import Flask, send_file, render_template
2
  import requests
3
  from io import BytesIO
4
- import os
5
 
6
- app = Flask(__name__)
7
- @app.route("/",methods=["GET", "POST"])
8
- def getInfotoMeasure():
 
 
 
 
9
  return render_template("gui.html")
 
10
  # Route to serve the PDF in iframe
11
  @app.route('/download-pdf', methods=['GET'])
12
  def download_pdf():
@@ -20,9 +24,11 @@ def download_pdf():
20
  dropbox_link = dropbox_link.replace('dl=0', 'dl=1')
21
 
22
  # Download the PDF content
23
- response = requests.get(dropbox_link)
24
- if response.status_code != 200:
25
- return "Failed to download the PDF.", 500
 
 
26
 
27
  pdf_content = BytesIO(response.content)
28
 
@@ -35,7 +41,5 @@ def download_pdf():
35
  )
36
 
37
  if __name__ == '__main__':
 
38
  app.run(host='0.0.0.0', port=7860)
39
-
40
- # if __name__ == '__main__':
41
- # app.run(host='0.0.0.0', port=7860, debug=True)
 
1
  from flask import Flask, send_file, render_template
2
  import requests
3
  from io import BytesIO
 
4
 
5
+ app = Flask(__name__)
6
+
7
+ @app.route("/", methods=["GET", "POST"])
8
+ def get_inf_to_measure():
9
+ """
10
+ Render the main GUI with the iframe.
11
+ """
12
  return render_template("gui.html")
13
+
14
  # Route to serve the PDF in iframe
15
  @app.route('/download-pdf', methods=['GET'])
16
  def download_pdf():
 
24
  dropbox_link = dropbox_link.replace('dl=0', 'dl=1')
25
 
26
  # Download the PDF content
27
+ try:
28
+ response = requests.get(dropbox_link)
29
+ response.raise_for_status() # Ensure the request was successful
30
+ except requests.exceptions.RequestException as e:
31
+ return f"Failed to download the PDF: {e}", 500
32
 
33
  pdf_content = BytesIO(response.content)
34
 
 
41
  )
42
 
43
  if __name__ == '__main__':
44
+ # Run the application with a specified host and port
45
  app.run(host='0.0.0.0', port=7860)