Marthee commited on
Commit
2e66bb1
·
verified ·
1 Parent(s): 023786f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -6,30 +6,30 @@ import os
6
  app = Flask(__name__)
7
  @app.route("/",methods=["GET", "POST"])
8
  def getInfotoMeasure():
9
- return render_template("view_pdf.html")
10
  # Route to serve the PDF in iframe
 
11
  @app.route('/view-pdf')
12
  def view_pdf():
13
  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'
14
 
15
- # Modify Dropbox link for direct download
16
  if 'dl=0' in link:
17
  link = link.replace('dl=0', 'dl=1')
18
 
19
- # Download PDF content
20
  response = requests.get(link)
 
21
  if response.status_code == 200:
22
  pdf_path = 'temp_view.pdf'
23
  with open(pdf_path, 'wb') as f:
24
  f.write(response.content)
25
-
26
- # Serve the PDF file
27
- return send_file(pdf_path, mimetype='application/pdf')
 
 
28
  else:
29
  return "Failed to download PDF content", 404
30
 
31
- # Run Flask server
32
-
33
  if __name__ == '__main__':
34
  app.run(host='0.0.0.0', port=7860)
35
  # from flask import Flask, request, jsonify
 
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
+
12
  @app.route('/view-pdf')
13
  def view_pdf():
14
  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'
15
 
 
16
  if 'dl=0' in link:
17
  link = link.replace('dl=0', 'dl=1')
18
 
 
19
  response = requests.get(link)
20
+
21
  if response.status_code == 200:
22
  pdf_path = 'temp_view.pdf'
23
  with open(pdf_path, 'wb') as f:
24
  f.write(response.content)
25
+
26
+ # Serve PDF with CSP header
27
+ response = send_file(pdf_path, mimetype='application/pdf')
28
+ response.headers['Content-Security-Policy'] = "frame-src *;"
29
+ return response
30
  else:
31
  return "Failed to download PDF content", 404
32
 
 
 
33
  if __name__ == '__main__':
34
  app.run(host='0.0.0.0', port=7860)
35
  # from flask import Flask, request, jsonify