diff options
-rw-r--r-- | database.py | 5 | ||||
-rw-r--r-- | flask_app.py | 4 | ||||
-rw-r--r-- | templates/file_list.html | 16 |
3 files changed, 25 insertions, 0 deletions
diff --git a/database.py b/database.py index 5f14801..29b687a 100644 --- a/database.py +++ b/database.py @@ -21,6 +21,11 @@ class DatabaseConnection(object): with closing(self.conn.cursor(MySQLdb.cursors.DictCursor)) as c: c.execute("select * from `groups`") return c.fetchall() + + def get_files(self): + with closing(self.conn.cursor(MySQLdb.cursors.DictCursor)) as c: + c.execute("select `files`.* from `files` inner join `groups` on `files`.`group_id` = `groups`.`id` order by `groups`.`date` desc") + return c.fetchall() def get_connection(user, passwd, db): conn = MySQLdb.connect(user=user, passwd=passwd, db=db) diff --git a/flask_app.py b/flask_app.py index 67b2217..6eeaa0c 100644 --- a/flask_app.py +++ b/flask_app.py @@ -27,6 +27,10 @@ def teardown_request(exception): def index(): return render_template('group_list.html', groups=g.db.get_groups()) +@app.route('/files') +def file_list(): + return render_template('file_list.html', files=g.db.get_files()) + @app.route('/submit', methods=['POST']) def submit(): submission = submission_pb2.Submission() diff --git a/templates/file_list.html b/templates/file_list.html new file mode 100644 index 0000000..8980776 --- /dev/null +++ b/templates/file_list.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% block title %}List of log files{% endblock %} +{% block body %} + <table> + <tr> + <th>group id</th> + <th>path</th> + </tr> + {% for file in files %} + <tr> + <td>{{ file.group_id }}</td> + <td>{{ file.path }}</td> + </tr> + {% endfor %} + </table> +{% endblock %} |