Spaces:
Running
Running
Download src/patch_qr.py from jzyg123/grade_query: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/jzyg123/grade_query/resolve/main/src/patch_qr.py
- Command line
-
hf download hf://spaces/jzyg123/grade_query/src/patch_qr.py
-
curl -L -o patch_qr.py https://huggingface.co/spaces/jzyg123/grade_query/resolve/main/src/patch_qr.py
1.27 kB
| import os | |
| with open('/Users/liruojuan/Library/CloudStorage/OneDrive-个人/Code/Python/Flask App/成绩查询/templates/login.html', 'r', encoding='utf-8') as f: | |
| text = f.read() | |
| text = text.replace( | |
| 'if (data.has_qr) {', | |
| '''window.lastQrUpdate = window.lastQrUpdate || 0; | |
| if (data.has_qr && data.status === 'waiting_login') {''' | |
| ) | |
| text = text.replace( | |
| '''qrImg.src = `/static/dingtalk_qr.png?t=${Date.now()}`;''', | |
| '''if (!qrImg.src || qrImg.src.indexOf('static/dingtalk_qr.png') === -1 || (Date.now() - window.lastQrUpdate > 3000)) { | |
| qrImg.src = `/static/dingtalk_qr.png?t=${Date.now()}`; | |
| window.lastQrUpdate = Date.now(); | |
| }''' | |
| ) | |
| text = text.replace( | |
| '''qrPlaceholder.style.display = 'none';\n }''', | |
| '''qrPlaceholder.style.display = 'none'; | |
| } else { | |
| qrImg.style.display = 'none'; | |
| qrImg.src = ''; | |
| qrPlaceholder.style.display = 'flex'; | |
| qrPlaceholder.innerHTML = '<span>' + (data.status === "done" ? "登录已完成" : (isError ? "抓取异常" : "暂无二维码")) + '</span>'; | |
| }''' | |
| ) | |
| with open('/Users/liruojuan/Library/CloudStorage/OneDrive-个人/Code/Python/Flask App/成绩查询/templates/login.html', 'w', encoding='utf-8') as f: | |
| f.write(text) | |