From 651b57be85e13b41aa23adb3994b5187b93d571e Mon Sep 17 00:00:00 2001 From: Hugo H Date: Fri, 28 Nov 2025 16:52:52 +0000 Subject: [PATCH] Fixed notes on read page --- main.py | 8 +++-- templates/notes.html | 4 ++- templates/read.html | 61 +++++++++++++++++++++++++++++++++++ textbooks/textbook1/notes.txt | 2 +- 4 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 templates/read.html diff --git a/main.py b/main.py index 4d6e086..62cd466 100644 --- a/main.py +++ b/main.py @@ -15,9 +15,11 @@ def readBook(): filepath = request.args.get('filepath')+"/book.md" with open(filepath) as f: mdtext = f.read() + notespath = request.args.get('filepath')+"/notes.txt" + with open(notespath) as f: + notestext = f.read() renderedMd = markdown.markdown(mdtext) - finalHTML = "Home" + renderedMd - return finalHTML + return render_template('read.html', markdown=renderedMd, path=request.args.get('filepath'), notes=notestext) @app.route('/notes') def notesForBook(): @@ -28,7 +30,7 @@ def notesForBook(): @app.route('/savenotes', methods=['POST']) def saveNotes(): - path = request.form.get("path") + path = request.form.get("path")+"/notes.txt" notes = request.form.get("notes") with open(path, "w") as f: f.write(notes) diff --git a/templates/notes.html b/templates/notes.html index 0fca9cf..0c9dd0e 100644 --- a/templates/notes.html +++ b/templates/notes.html @@ -33,11 +33,13 @@ } Home (No save) +
- +
+
\ No newline at end of file diff --git a/templates/read.html b/templates/read.html new file mode 100644 index 0000000..62e89f3 --- /dev/null +++ b/templates/read.html @@ -0,0 +1,61 @@ + + + + + + Read book + + + + Home +
+
{{ markdown | safe }}
+ +
+ + \ No newline at end of file diff --git a/textbooks/textbook1/notes.txt b/textbooks/textbook1/notes.txt index 3710ec8..bd41cba 100644 --- a/textbooks/textbook1/notes.txt +++ b/textbooks/textbook1/notes.txt @@ -1 +1 @@ -My notes \ No newline at end of file +12345 \ No newline at end of file