From 5c567070fc3a18ae08c7d4b5ffa9af5ae3a72e5e Mon Sep 17 00:00:00 2001 From: Antanas Uršulis Date: Fri, 2 Aug 2013 10:12:25 +0300 Subject: Simple file list template TODO: it should provide a link to file, instead of printing the path. --- database.py | 5 +++++ flask_app.py | 4 ++++ templates/file_list.html | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 templates/file_list.html 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 %} + + + + + + {% for file in files %} + + + + + {% endfor %} +
group idpath
{{ file.group_id }}{{ file.path }}
+{% endblock %} -- cgit v1.2.3-65-gdbad