"""在容器内运行,渲染 scan 端点的实际 HTML 输出""" import sys sys.path.insert(0, '/app') # 模拟 f-string 中的变量 user_name = "测试用户" jsapi_signature = "test_sig_abc123" jsapi_timestamp = 1752105600 jsapi_nonce = "test_nonce_xyz" jsapi_appid = "ww_test_corp_id" current_url = "https://itsupport.servyou.com.cn/api/auth_qrcode/scan?code=test&state=test" html = f""" 登录成功 - IT智能服务台

登录成功

已自动确认登录

你好,{user_name}
请返回电脑端查看

签名: {'成功' if jsapi_signature else '未生成'}
URL: {current_url}
状态: JS加载中...
""" # 保存渲染后的 HTML with open('/tmp/test_scan.html', 'w', encoding='utf-8') as f: f.write(html) print(f"HTML rendered: {len(html)} chars") print("Saved to /tmp/test_scan.html") # 检查 script 部分 import re script_match = re.search(r'', html, re.DOTALL) if script_match: js = script_match.group(1) print(f"\nJS section: {len(js)} chars") # 检查是否有 {{ 残留(f-string 未正确渲染) if '{{' in js: print("ERROR: Found unrendered {{ in JS!") for i, line in enumerate(js.split('\n')): if '{{' in line: print(f" Line {i+1}: {line.strip()[:80]}") else: print("OK: No unrendered braces in JS") # 打印前 20 行 JS print("\nFirst 20 lines of rendered JS:") for i, line in enumerate(js.split('\n')[:20]): print(f" {i+1}: {line}")