Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,46 +9,28 @@ def getInfotoMeasure():
|
|
| 9 |
return render_template("gui.html")
|
| 10 |
# Route to serve the PDF in iframe
|
| 11 |
|
| 12 |
-
@app.route('/
|
| 13 |
-
def
|
|
|
|
| 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 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 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
|
| 36 |
-
|
| 37 |
-
# app = Flask(__name__)
|
| 38 |
-
|
| 39 |
-
# @app.route('/api/process-data', methods=['POST'])
|
| 40 |
-
# def process_data():
|
| 41 |
-
# # Get JSON data from the request
|
| 42 |
-
# data = request.get_json()
|
| 43 |
-
|
| 44 |
-
# # Perform some processing on the data
|
| 45 |
-
# # For example, let's just return the data back with a message
|
| 46 |
-
# processed_data = {
|
| 47 |
-
# 'message': 'Data received and processed successfully!',
|
| 48 |
-
# 'received_data': data
|
| 49 |
-
# }
|
| 50 |
-
|
| 51 |
-
# return jsonify(processed_data)
|
| 52 |
|
| 53 |
# if __name__ == '__main__':
|
| 54 |
# app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
|
| 9 |
return render_template("gui.html")
|
| 10 |
# Route to serve the PDF in iframe
|
| 11 |
|
| 12 |
+
@app.route('/pdf', methods=['GET'])
|
| 13 |
+
def serve_pdf():
|
| 14 |
+
# Dropbox link
|
| 15 |
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'
|
| 16 |
|
| 17 |
+
# Convert Dropbox link for direct download
|
| 18 |
if 'dl=0' in link:
|
| 19 |
link = link.replace('dl=0', 'dl=1')
|
| 20 |
|
| 21 |
+
# Download the PDF content
|
| 22 |
response = requests.get(link)
|
| 23 |
+
pdf_content = BytesIO(response.content)
|
| 24 |
|
| 25 |
+
# Serve the PDF
|
| 26 |
+
return send_file(
|
| 27 |
+
pdf_content,
|
| 28 |
+
download_name="document.pdf", # Name the file
|
| 29 |
+
mimetype="application/pdf"
|
| 30 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
if __name__ == '__main__':
|
| 33 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# if __name__ == '__main__':
|
| 36 |
# app.run(host='0.0.0.0', port=7860, debug=True)
|