From 87ea87a2e936b4fab9a24897a69dfa74749ad07a Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 14 Aug 2020 19:29:59 +0200 Subject: [PATCH] update modules, move markdown requirement and add tutorial caching --- WebHostLib/__init__.py | 6 ++++-- WebHostLib/requirements.txt | 3 ++- requirements.txt | 5 ++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/WebHostLib/__init__.py b/WebHostLib/__init__.py index 8a9602de..cc804850 100644 --- a/WebHostLib/__init__.py +++ b/WebHostLib/__init__.py @@ -76,12 +76,14 @@ def register_session(): @app.route('/tutorial') @app.route('/tutorial/') +@cache.memoize(timeout=300) # update every 300 seconds def tutorial(lang='en'): try: - md_file = open(f'WebHostLib/tutorial/tutorial_{lang}.md', 'r', encoding="utf-8") - return render_template("tutorial.html", tutorial=markdown.markdown(md_file.read())) + md_file = open(os.path.join('WebHostLib', 'tutorial', f"tutorial_{lang}.md"), encoding="utf-8-sig") except FileNotFoundError: return render_template("tutorial.html", tutorial='The tutorial is not available in that language yet, sorry.') + else: + return render_template("tutorial.html", tutorial=markdown.markdown(md_file.read())) @app.route('/seed/') diff --git a/WebHostLib/requirements.txt b/WebHostLib/requirements.txt index 63b0e1d3..27e0aac8 100644 --- a/WebHostLib/requirements.txt +++ b/WebHostLib/requirements.txt @@ -4,4 +4,5 @@ waitress>=1.4.4 flask-caching>=1.9.0 Flask-Autoversion>=0.2.0 Flask-Compress>=1.5.0 -Flask-Limiter>=1.3.1 \ No newline at end of file +Flask-Limiter>=1.3.1 +markdown>=3.2.2 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b0b55823..259195ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ colorama>=0.4.3 websockets>=8.1 PyYAML>=5.3.1 fuzzywuzzy>=0.18.0 -bsdiff4>=1.1.9 -prompt_toolkit>=3.0.5 +bsdiff4>=1.2.0 +prompt_toolkit>=3.0.6 appdirs>=1.4.4 -markdown>=3.2.2