瀏覽代碼

displaying nicely, still working on details, highlighting and capturing input data

bscheibel 4 年之前
父節點
當前提交
8a52a8e09a
共有 6 個文件被更改,包括 61 次插入14 次删除
  1. 1 0
      app/__init__.py
  2. 11 1
      app/static/css/style.css
  3. 4 1
      app/static/js/url.js
  4. 0 1
      app/templates/display_results.html
  5. 26 5
      app/templates/show_image.html
  6. 19 6
      app/views.py

+ 1 - 0
app/__init__.py

@@ -1,6 +1,7 @@
 from flask import Flask
 
 app = Flask(__name__)
+app.debug = True
 app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
 
 from app import views

+ 11 - 1
app/static/css/style.css

@@ -45,7 +45,7 @@ img {
 
     /*for demo purposes only */
     background: #f2f2f2;
-    border: 1px solid #e6e6e6;
+    /*border: 1px solid #e6e6e6;*/
     box-sizing: border-box;
 }
 .column-one {
@@ -61,3 +61,13 @@ img {
 @media (max-width: 50em) { /* 2 x 15em (.text & .images) + 2em  (left & right margin of the body element) + 1em (.text margin-right)  */
   .container {flex-wrap: wrap}
 }
+
+.red{
+background: red;
+opacity: 0.4;
+width: 20px;
+height: 20px;
+position: absolute;
+left: 0px;
+top: 0px;
+}

+ 4 - 1
app/static/js/url.js

@@ -1,5 +1,5 @@
 
-function createDynamicURL(k)
+function submit_save(k)
 {
     //The variable to be returned
     var URL;
@@ -7,3 +7,6 @@ function createDynamicURL(k)
 
     return URL;
 }
+
+
+

+ 0 - 1
app/templates/display_results.html

@@ -4,7 +4,6 @@
     <meta charset="UTF-8">
     <title>Title</title>
 
-    {{ text }}
 </head>
 <body>
 

+ 26 - 5
app/templates/show_image.html

@@ -2,6 +2,22 @@
 <head>
   <title>Dimension Extraction</title>
   <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"/>
+<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
+<script>
+
+$(document).ready(function(){
+
+    $("#myInput").on("input", function(){
+
+        // Print entered value in a div box
+
+        $("#result").text($(this).val());
+
+    });
+
+});
+
+</script>
 </head>
 
 <body>
@@ -13,6 +29,7 @@
         {% if filename %}
         <div class="images">
             <img src="{{ url_for('send_file', filename=filename) }}"/>
+            <div class="red" ></div>
         </div>
         {% else %}
         <h1>no image for whatever reason</h1>
@@ -22,23 +39,27 @@
     <div class="column column-two">
             <h1>Extracted Measurements</h1>
                 <font size="3" face="Courier New" >
-                <form method="post" action="{{ url_for('form_post') }}">
+                <form method="post">
                 <table>
                     <tr>
                         <td style="text-align:center"><h3>Key Value</h3></td>
                         <td style="text-align:center"><h3>Target Value</h3></td>
                         <td style="text-align:center"><h3>Actual Value</h3></td>
                     </tr>
-                   {% for key in dims %}
+
+                        {{ text | safe}}
+
+
+                 <!--  {% for key in dims %}
                     <td><h4> {{key}} </h4></td>
                         {% for d in dims[key] %}
                     <tr>
-                        <td style="text-align:center"><input type="checkbox" name="relevant" value="checked"></td>
+                        <td style="text-align:center"><input type="checkbox" name="relevant[]" value="checked"></td>
                         <td style="text-align:center"> {{ d }}</td>
-                        <td style="text-align:center"><input type="text" name="actual" size="10"></td>
+                        <td style="text-align:center"><input type="text" name="{{ d }}" size="10"></td>
                     </tr>
                         {% endfor %}
-                    {% endfor %}
+                    {% endfor %}-->
 
 
                 </table>

+ 19 - 6
app/views.py

@@ -50,6 +50,8 @@ def upload_file():
 @app.route('/show/<filename>&<uuid>')
 def uploaded_file(filename, uuid):
     file_out = "out.jpg"
+    if request.method == 'POST':
+        uuid = 433
     if filename.endswith(".pdf") or filename.endswith(".PDF"):
         convert_pdf_img(filename)
         db = redis.Redis("localhost")
@@ -57,7 +59,16 @@ def uploaded_file(filename, uuid):
         #print(iso)
         isos = json.loads(db.get(uuid+"isos"))
         dims = json.loads(db.get(uuid+"dims"))
-        return render_template('show_image.html', filename=file_out, isos=isos, dims=dims)
+        html_code = ""
+       # dims = eval(dims)
+        for dim in dims:
+            html_code += '''<td><h4>''' + dim + '''</h4></td>'''
+            for d in dims[dim]:
+                html_code += "<tr><td style='text-align:center'> <input type='checkbox' name='relevant." + d + "' value='checked'  onchange='submit()'> </td>" + \
+                             "<td style='text-align:center'>" + d + "</td>" + \
+                             "<td style='text-align:center'> <input type='number' name='" + d + "' value='" + d + "'  size='10'  onchange='submit()'> </td></tr>"
+                print(html_code)
+        return render_template('show_image.html', filename=file_out, isos=isos, dims=dims, text=html_code)
 
     else:
         filename = filename
@@ -81,15 +92,17 @@ def add_header(response):
 def generate(name):
     name = name.replace(" ","")
     url = name+".PDF"
-    url1 = "./static/isos/"+url
-    print(url1)
     try:
         file = send_from_directory("static/isos",url)
         return file
     except:
         return"Sorry file not found"
 
-@app.route('/show_results', methods=['POST'])
+@app.route('/show_results')
 def form_post():
-    text = request.args.get("form")
-    return render_template('display_results.html', text=text)
+    text = []
+    db = redis.Redis('localhost')
+    for key in request.form:
+        db.set(key, request.form[key])
+    return render_template('display_results.html')
+