From 843bae8fa0c80f755e4eae1e9f1251e1fce5b73e Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Fri, 23 Dec 2016 00:41:14 -0500 Subject: [PATCH] init commit --- bash.py | 38 +++++++++++++++++++++++++++++++++++++ templates/show_entries.html | 15 +++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 bash.py create mode 100644 templates/show_entries.html diff --git a/bash.py b/bash.py new file mode 100644 index 0000000..991a6eb --- /dev/null +++ b/bash.py @@ -0,0 +1,38 @@ +from flask import Flask, render_template +import os + +app = Flask(__name__) + + +@app.route("/") +def show_entries(): + bash_quotes = 'bash_logs' + bash_quotes_path = os.path.join(os.path.expanduser('~/.phenny'), bash_quotes) + + if not os.path.exists(bash_quotes_path): + return + + files = os.listdir(bash_quotes_path) + for i in range(len(files)): + files[i] = files[i].replace('.txt', '') + files[i] = int(files[i]) + files.sort() + for i in range(len(files)): + files[i] = ''.join([str(files[i]), '.txt']) + + files_contents = [] + for f in files: + f = os.path.join(bash_quotes_path, f) + with open(f) as fOpen: + content = fOpen.readlines() + files_contents.append(content) + + for files in files_contents: + for line in files: + line = line.replace('<', '<') + line = line.replace('>', '>') + + return render_template('show_entries.html', entries=files_contents, i=range(len(files_contents))) + +if __name__ == "__main__": + app.run() diff --git a/templates/show_entries.html b/templates/show_entries.html new file mode 100644 index 0000000..225d8e2 --- /dev/null +++ b/templates/show_entries.html @@ -0,0 +1,15 @@ + +vtbash +{% block body %} + {% for j in i %} +

+ #{{ j + 1 }}
+ {% for line in entries[j] %} + {{ line }}
+ {% endfor %} +

+
+ {% else %} +

Unbelievable. No Entries here so far

+ {% endfor %} +{% endblock %}