From 9cf08172fea75ee9b34e1cd452631613decf4f1c Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 22 Jul 2023 17:46:50 -0700 Subject: refactor(hayai): template-ize response --- hayai/__init__.py | 78 ++++++++++--------------------------------------------- 1 file changed, 13 insertions(+), 65 deletions(-) diff --git a/hayai/__init__.py b/hayai/__init__.py index 3a453e2..15be293 100644 --- a/hayai/__init__.py +++ b/hayai/__init__.py @@ -59,43 +59,10 @@ def upload_file(): # Prompt user to download "bionic" EPUB return redirect(url_for("download_file", name=filename)) - return """ - - - - はやい - - - - - - - - - - -

はやい

- -
Upload an EPUB, receive a "bionic" EPUB.
- -
- - -
- -
- - Need to reed? - -
-
- -
- - This project is licensed with the GNU General Public License v3.0. - - -""" + return page( + '
Upload an EPUB, receive a "bionic" EPUB.
', + 'Want to read an EPUB?', + ) @app.route("/reader", methods=["GET", "POST"]) @@ -133,35 +100,16 @@ def reader(): .replace("\n", "
") ) - return f""" - - - - はやい - - - - - - - - - - -

はやい

- - {output} - -
+ return page(output, 'Want to read another EPUB?') -
+ return page( + "
Upload an EPUB, read it in plain-text.
", + 'Want to convert an EPUB?', + ) - This project is licensed with the GNU General Public License v3.0. - - - """ - return """ +def page(main_content: str, footer: str) -> str: + return f""" @@ -178,7 +126,7 @@ def reader():

はやい

-
Upload an EPUB, read it in plain-text.
+ {main_content}
@@ -189,7 +137,7 @@ def reader():
- This project is licensed with the GNU General Public License v3.0. +

{footer}

""" -- cgit v1.2.3