diff options
author | 2013-08-02 10:12:25 +0300 | |
---|---|---|
committer | 2013-08-02 10:12:25 +0300 | |
commit | 5c567070fc3a18ae08c7d4b5ffa9af5ae3a72e5e (patch) | |
tree | c54748a73d340a7f6e2ee25b662ce376fc132cb7 | |
parent | Group list view (diff) | |
download | log-analysis-5c567070fc3a18ae08c7d4b5ffa9af5ae3a72e5e.tar.gz log-analysis-5c567070fc3a18ae08c7d4b5ffa9af5ae3a72e5e.tar.bz2 log-analysis-5c567070fc3a18ae08c7d4b5ffa9af5ae3a72e5e.zip |
TODO: it should provide a link to file, instead of printing the path.
-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 %} |