|
@@ -1,3 +1,4 @@
|
|
|
|
+#encoding
|
|
from app import app
|
|
from app import app
|
|
from flask import request, redirect, url_for, send_from_directory, render_template
|
|
from flask import request, redirect, url_for, send_from_directory, render_template
|
|
import subprocess
|
|
import subprocess
|
|
@@ -7,6 +8,7 @@ import json
|
|
import os
|
|
import os
|
|
import json
|
|
import json
|
|
import re
|
|
import re
|
|
|
|
+import base64
|
|
#https://medium.com/@emerico/convert-pdf-to-image-using-python-flask-2864fb655e01
|
|
#https://medium.com/@emerico/convert-pdf-to-image-using-python-flask-2864fb655e01
|
|
|
|
|
|
|
|
|
|
@@ -27,7 +29,7 @@ def convert_pdf_img(filename):
|
|
|
|
|
|
def extract_all(uuid, filename, db):
|
|
def extract_all(uuid, filename, db):
|
|
#order_bounding_boxes_in_each_block.main(uuid, UPLOAD_FOLDER + "/" + filename)
|
|
#order_bounding_boxes_in_each_block.main(uuid, UPLOAD_FOLDER + "/" + filename)
|
|
- subprocess.call(['python3','/home/bscheibel/PycharmProjects/dxf_reader/main.py', str(uuid),UPLOAD_FOLDER + "/" + filename, db, str(1)])
|
|
|
|
|
|
+ subprocess.call(['python3','/home/bscheibel/PycharmProjects/dxf_reader/main.py', str(uuid),UPLOAD_FOLDER + "/" + filename, db, str(0)])
|
|
|
|
|
|
@app.route('/', methods=['GET', 'POST'])
|
|
@app.route('/', methods=['GET', 'POST'])
|
|
def upload_file():
|
|
def upload_file():
|
|
@@ -52,6 +54,7 @@ def upload_file():
|
|
@app.route('/show/<filename>&<uuid>')
|
|
@app.route('/show/<filename>&<uuid>')
|
|
def uploaded_file(filename, uuid):
|
|
def uploaded_file(filename, uuid):
|
|
file_out = "out.jpg"
|
|
file_out = "out.jpg"
|
|
|
|
+ #file_out = filename
|
|
if request.method == 'POST':
|
|
if request.method == 'POST':
|
|
uuid = 433
|
|
uuid = 433
|
|
if filename.endswith(".pdf") or filename.endswith(".PDF"):
|
|
if filename.endswith(".pdf") or filename.endswith(".PDF"):
|
|
@@ -61,19 +64,34 @@ def uploaded_file(filename, uuid):
|
|
#print(iso)
|
|
#print(iso)
|
|
isos = json.loads(db.get(str(uuid)+"isos"))
|
|
isos = json.loads(db.get(str(uuid)+"isos"))
|
|
dims = json.loads(db.get(str(uuid)+"dims"))
|
|
dims = json.loads(db.get(str(uuid)+"dims"))
|
|
|
|
+ number_blocks = db.get(str(uuid)+"eps")
|
|
html_code = ""
|
|
html_code = ""
|
|
reg = r"(-?\d{1,}\.?\d*)"
|
|
reg = r"(-?\d{1,}\.?\d*)"
|
|
for dim in dims:
|
|
for dim in dims:
|
|
html_code += '''<td><h4>''' + dim + '''</h4></td>'''
|
|
html_code += '''<td><h4>''' + dim + '''</h4></td>'''
|
|
for d in dims[dim]:
|
|
for d in dims[dim]:
|
|
- number = re.search(reg, d)
|
|
|
|
|
|
+ number = d
|
|
|
|
+
|
|
|
|
+ """ number = re.search(reg, d)
|
|
number = number.group(1)
|
|
number = number.group(1)
|
|
|
|
+ try:
|
|
|
|
+ floats = len(number.split(".")[1])
|
|
|
|
+ if floats <= 1:
|
|
|
|
+ steps = 0.1
|
|
|
|
+ elif floats == 2:
|
|
|
|
+ steps = 0.01
|
|
|
|
+ elif floats == 3:
|
|
|
|
+ steps = 0.001
|
|
|
|
+ else:
|
|
|
|
+ steps = 0.001
|
|
|
|
+ except: """
|
|
|
|
+ steps = 0.1
|
|
coords = ",".join(str(e) for e in dims[dim][d])
|
|
coords = ",".join(str(e) for e in dims[dim][d])
|
|
html_code += "<tr><td style='text-align:center'> <input type='checkbox' name='relevant." + d + "' value='checked'> </td>" + \
|
|
html_code += "<tr><td style='text-align:center'> <input type='checkbox' name='relevant." + d + "' value='checked'> </td>" + \
|
|
"<td style='text-align:center'>" + d + "</td>" + \
|
|
"<td style='text-align:center'>" + d + "</td>" + \
|
|
- "<td style='text-align:center'> <input type='number' step=0.01 data-coords='" + coords + "' name='" + d + "' value='" + number + "' size='10'> </td></tr>"
|
|
|
|
|
|
+ "<td style='text-align:center'> <input type='number' step='" + str(steps) + "' data-coords='" + coords + "' name='" + d + "' value='" + number + "' size='10'> </td></tr>"
|
|
#print(html_code)
|
|
#print(html_code)
|
|
- return render_template('show_image.html', filename=file_out, isos=isos, dims=dims, text=html_code)
|
|
|
|
|
|
+ return render_template('show_image.html', filename=file_out, isos=isos, dims=dims, text=html_code, number=number_blocks)
|
|
|
|
|
|
else:
|
|
else:
|
|
filename = filename
|
|
filename = filename
|
|
@@ -90,6 +108,9 @@ def add_header(response):
|
|
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
|
|
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
|
|
response.headers['Pragma'] = 'no-cache'
|
|
response.headers['Pragma'] = 'no-cache'
|
|
response.headers['Expires'] = '-1'
|
|
response.headers['Expires'] = '-1'
|
|
|
|
+ response.headers['Access-Control-Allow-Origin'] = '*'
|
|
|
|
+ response.headers.add("Access-Control-Allow-Headers", "*")
|
|
|
|
+ response.headers.add("Access-Control-Allow-Methods", "*")
|
|
return response
|
|
return response
|
|
|
|
|
|
|
|
|
|
@@ -103,11 +124,22 @@ def generate(name):
|
|
except:
|
|
except:
|
|
return"Sorry file not found"
|
|
return"Sorry file not found"
|
|
|
|
|
|
-"""@app.route('/show_results')
|
|
|
|
-def form_post():
|
|
|
|
- text = []
|
|
|
|
- db = redis.Redis('localhost')
|
|
|
|
- for key in request.form:
|
|
|
|
- db.set(key, request.form[key])
|
|
|
|
- return render_template('display_results.html'"""
|
|
|
|
|
|
+@app.route('/redis/get/<key>',methods=['GET'])
|
|
|
|
+def redis_get(key):
|
|
|
|
+ db = redis.Redis("localhost")
|
|
|
|
+ result = json.loads(db.get(key))
|
|
|
|
+ return result
|
|
|
|
+
|
|
|
|
+@app.route('/redis/set/<key>/<value>',methods=['POST'])
|
|
|
|
+def redis_set(key, value):
|
|
|
|
+ db = redis.Redis("localhost")
|
|
|
|
+ try:
|
|
|
|
+ result = json.loads(db.get(key))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ key = key.encode("utf-8")
|
|
|
|
+ result = db.set(key, str(value))
|
|
|
|
+ else:
|
|
|
|
+ db.set( )
|
|
|
|
+ return "OK"
|
|
|
|
|