Update app.py
Browse files
app.py
CHANGED
@@ -54,12 +54,15 @@ def index():
|
|
54 |
|
55 |
# JavaScriptコードを追加する部分
|
56 |
js_code = """
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
const img = document.createElement('img');
|
64 |
img.src = 'https://huggingface.co/spaces/soiz/cookie/raw/main/1.png';
|
65 |
img.style.position = 'fixed';
|
@@ -67,20 +70,26 @@ def index():
|
|
67 |
img.style.left = '0';
|
68 |
img.style.width = '100vw';
|
69 |
img.style.height = '100vh';
|
70 |
-
img.style.zIndex = '
|
71 |
document.body.appendChild(img);
|
72 |
-
} else if (data === 0) {
|
73 |
-
const existingImg = document.querySelector('img');
|
74 |
-
if (existingImg) {
|
75 |
-
existingImg.remove();
|
76 |
-
}
|
77 |
}
|
78 |
-
})
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
"""
|
85 |
|
86 |
# index.htmlのbodyタグの前にJavaScriptを追加
|
|
|
54 |
|
55 |
# JavaScriptコードを追加する部分
|
56 |
js_code = """
|
57 |
+
<script>
|
58 |
+
setInterval(() => {
|
59 |
+
fetch('https://huggingface.co/spaces/soiz/cookie/raw/main/tof')
|
60 |
+
.then(response => response.json())
|
61 |
+
.then(data => {
|
62 |
+
if (data === 1) {
|
63 |
+
// 既存の画像を削除
|
64 |
+
const existingImg = document.querySelector('img');
|
65 |
+
if (!existingImg) { // 画像がまだ存在しない場合のみ追加
|
66 |
const img = document.createElement('img');
|
67 |
img.src = 'https://huggingface.co/spaces/soiz/cookie/raw/main/1.png';
|
68 |
img.style.position = 'fixed';
|
|
|
70 |
img.style.left = '0';
|
71 |
img.style.width = '100vw';
|
72 |
img.style.height = '100vh';
|
73 |
+
img.style.zIndex = '999999999999999999999999999999999999999999999999999999999999999999999999999999999999999';
|
74 |
document.body.appendChild(img);
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
+
} else if (data === 0) {
|
77 |
+
// 画像が存在する場合にのみ削除
|
78 |
+
const existingImg = document.querySelector('img');
|
79 |
+
if (existingImg) {
|
80 |
+
// 画像を削除
|
81 |
+
existingImg.remove();
|
82 |
+
// 念のためhidden=trueを設定
|
83 |
+
existingImg.hidden = true;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
})
|
87 |
+
.catch(error => {
|
88 |
+
// エラー時の処理は特にしない
|
89 |
+
});
|
90 |
+
}, 10000); // 10秒ごとにリクエストを送信
|
91 |
+
</script>
|
92 |
+
|
93 |
"""
|
94 |
|
95 |
# index.htmlのbodyタグの前にJavaScriptを追加
|