Parcourir la source

Display recent public results on the home page

Baptiste Jonglez il y a 10 ans
Parent
commit
b135f6dda7
2 fichiers modifiés avec 23 ajouts et 2 suppressions
  1. 2 1
      peerfinder.py
  2. 21 1
      templates/home.html

+ 2 - 1
peerfinder.py

@@ -181,7 +181,8 @@ def get_targets(uuid):
 
 @app.route('/')
 def homepage():
-    return render_template('home.html')
+    public_targets = Target.query.filter_by(public=True).order_by("submitted DESC").all()
+    return render_template('home.html', targets=public_targets)
 
 @app.route('/about')
 def about():

+ 21 - 1
templates/home.html

@@ -17,6 +17,8 @@ latency from various points in the network towards you.</p>
   </ol>
 </p>
 
+<h3>Launch a measurement</h3>
+
 <p>
 <form action="/submit" method="POST">
 <label for="target">Target:</label>
@@ -28,7 +30,25 @@ latency from various points in the network towards you.</p>
 </p>
 
 <p>If you mark your measurement as public, it will be displayed on the
-home page.  Note that the IP addresses of the target will be shown
+home page below.  Note that the IP addresses of the target will be shown
 alongside the result.</p>
 
+<h2>Recent measurements</h2>
+
+<table>
+  <tr>
+    <th>Date</th>
+    <th>Target</th>
+    <th>Result</th>
+  </tr>
+  {% for t in targets %}
+  <tr>
+    <td>{{ t.submitted.strftime('%Y-%m-%d %H:%M') }}</td>
+    <td>{{ t.get_ip() }}</td>
+    <td><a href="/result/show/{{ t.unique_id }}">View result</a></td>
+  </tr>
+  {% endfor %}
+</table>
+
+
 {% endblock %}