暂存-说明文档(部分)
This commit is contained in:
@@ -228,6 +228,26 @@ def control():
|
||||
error = "OctoPrint is not configured."
|
||||
return render_template('printer/control.html', webcam_url=webcam_url, error=error)
|
||||
|
||||
import re
|
||||
import markdown
|
||||
|
||||
@printer_bp.route('/helper_printer')
|
||||
def helper_printer():
|
||||
lang = request.cookies.get('lang', 'en')
|
||||
filepath = os.path.join(current_app.root_path, 'assets', 'doc', f'printer_helper_{lang}.md')
|
||||
if not os.path.exists(filepath):
|
||||
filepath = os.path.join(current_app.root_path, 'assets', 'doc', 'printer_helper_en.md')
|
||||
|
||||
content_html = ""
|
||||
if os.path.exists(filepath):
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
md_text = f.read()
|
||||
content_html = markdown.markdown(md_text, extensions=['fenced_code', 'tables'])
|
||||
# Rewrite relative image links to /assets/doc/
|
||||
content_html = re.sub(r'src="(?!http|/)([^"]+)"', r'src="/assets/doc/\1"', content_html)
|
||||
|
||||
return render_template('printer/helper_printer.html', content_html=content_html)
|
||||
|
||||
@printer_bp.route('/api/command', methods=['POST'])
|
||||
@login_required
|
||||
def api_command():
|
||||
@@ -456,7 +476,9 @@ def octo_proxy(path):
|
||||
class WebSocketResponse(Response):
|
||||
def __call__(self, *args, **kwargs):
|
||||
print("WS Response __call__")
|
||||
if getattr(ws, 'mode', 'werkzeug') == 'werkzeug':
|
||||
if getattr(ws, 'mode', 'werkzeug') == 'gunicorn':
|
||||
raise StopIteration()
|
||||
elif getattr(ws, 'mode', 'werkzeug') == 'werkzeug':
|
||||
return super().__call__(*args, **kwargs)
|
||||
return []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user