update modules, move markdown requirement and add tutorial caching

This commit is contained in:
Fabian Dill 2020-08-14 19:29:59 +02:00
parent 6c29f86115
commit 87ea87a2e9
3 changed files with 8 additions and 6 deletions

View File

@ -76,12 +76,14 @@ def register_session():
@app.route('/tutorial') @app.route('/tutorial')
@app.route('/tutorial/<string:lang>') @app.route('/tutorial/<string:lang>')
@cache.memoize(timeout=300) # update every 300 seconds
def tutorial(lang='en'): def tutorial(lang='en'):
try: try:
md_file = open(f'WebHostLib/tutorial/tutorial_{lang}.md', 'r', encoding="utf-8") md_file = open(os.path.join('WebHostLib', 'tutorial', f"tutorial_{lang}.md"), encoding="utf-8-sig")
return render_template("tutorial.html", tutorial=markdown.markdown(md_file.read()))
except FileNotFoundError: except FileNotFoundError:
return render_template("tutorial.html", tutorial='The tutorial is not available in that language yet, sorry.') 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/<suuid:seed>') @app.route('/seed/<suuid:seed>')

View File

@ -4,4 +4,5 @@ waitress>=1.4.4
flask-caching>=1.9.0 flask-caching>=1.9.0
Flask-Autoversion>=0.2.0 Flask-Autoversion>=0.2.0
Flask-Compress>=1.5.0 Flask-Compress>=1.5.0
Flask-Limiter>=1.3.1 Flask-Limiter>=1.3.1
markdown>=3.2.2

View File

@ -2,7 +2,6 @@ colorama>=0.4.3
websockets>=8.1 websockets>=8.1
PyYAML>=5.3.1 PyYAML>=5.3.1
fuzzywuzzy>=0.18.0 fuzzywuzzy>=0.18.0
bsdiff4>=1.1.9 bsdiff4>=1.2.0
prompt_toolkit>=3.0.5 prompt_toolkit>=3.0.6
appdirs>=1.4.4 appdirs>=1.4.4
markdown>=3.2.2