Marthee commited on
Commit
ad44689
·
verified ·
1 Parent(s): a2902ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -25
app.py CHANGED
@@ -13,32 +13,14 @@ def get_inf_to_measure():
13
 
14
  # Route to serve the PDF in iframe
15
  @app.route('/download-pdf', methods=['GET'])
16
- def download_pdf():
17
- """
18
- Download the PDF from Dropbox and serve it for iframe embedding.
19
- """
20
- dropbox_link = 'https://www.dropbox.com/scl/fi/fjykwhhn9gu9t3kqrflxd/LA002-NOR-ZZ-ZZ-T-A-2403_Architectural-Specification-F10-Brick-and-Block-Walling_A4-_C01.pdf?rlkey=ek9i66i79m0hwp8z5yjs6rp5p&st=jh05a6qs&dl=0'
21
-
22
- # Modify Dropbox link to enable direct download
23
- if 'dl=0' in dropbox_link:
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
-
35
- # Serve the PDF
36
- return send_file(
37
- pdf_content,
38
- mimetype='application/pdf',
39
- as_attachment=False,
40
- download_name="downloaded_document.pdf"
41
- )
42
 
43
  if __name__ == '__main__':
44
  # Run the application with a specified host and port
 
13
 
14
  # Route to serve the PDF in iframe
15
  @app.route('/download-pdf', methods=['GET'])
16
+ def serve_pdf():
17
+ link = 'https://www.dropbox.com/scl/fi/fjykwhhn9gu9t3kqrflxd/LA002-NOR-ZZ-ZZ-T-A-2403_Architectural-Specification-F10-Brick-and-Block-Walling_A4-_C01.pdf?rlkey=ek9i66i79m0hwp8z5yjs6rp5p&st=jh05a6qs&dl=0'
18
+ if 'dl=0' in link:
19
+ link = link.replace('dl=0', 'dl=1')
20
+ response = requests.get(link)
 
 
 
 
 
 
 
 
 
 
 
 
21
  pdf_content = BytesIO(response.content)
22
+ return send_file(pdf_content, download_name="document.pdf", mimetype="application/pdf")
23
+
 
 
 
 
 
 
24
 
25
  if __name__ == '__main__':
26
  # Run the application with a specified host and port