Update app.py
Browse files
app.py
CHANGED
|
@@ -2100,38 +2100,46 @@ with gr.Blocks(title="DenAIGeo β Dengue Origin Tracer") as demo:
|
|
| 2100 |
|
| 2101 |
demo.queue(default_concurrency_limit=1)
|
| 2102 |
|
| 2103 |
-
#
|
| 2104 |
-
#
|
| 2105 |
-
#
|
| 2106 |
-
#
|
| 2107 |
-
#
|
| 2108 |
-
#
|
| 2109 |
-
#
|
| 2110 |
-
#
|
| 2111 |
-
#
|
| 2112 |
-
|
| 2113 |
-
|
| 2114 |
-
|
| 2115 |
-
# 3) νΉμ μ΄νμλ 'dark' ν΄λμ€κ° μ΄λκ°μ λ¨μμλ€λ©΄ κ³μ μ κ±°ν©λλ€(보쑰 μλ¨).
|
| 2116 |
-
_PAGE_LOAD_JS = """
|
| 2117 |
-
function() {
|
| 2118 |
-
// --- (2) matchMedia ν¨μΉ: κ°μ₯ λ¨Όμ , ν λ²λ§ ---
|
| 2119 |
if (window.matchMedia && !window._denaigeoMatchMediaPatched) {
|
| 2120 |
window._denaigeoMatchMediaPatched = true;
|
| 2121 |
-
|
| 2122 |
window.matchMedia = function(query) {
|
| 2123 |
if (typeof query === 'string' && query.indexOf('prefers-color-scheme') !== -1 && query.indexOf('dark') !== -1) {
|
| 2124 |
return {
|
| 2125 |
matches: false, media: query, onchange: null,
|
| 2126 |
addListener: function() {}, removeListener: function() {},
|
| 2127 |
addEventListener: function() {}, removeEventListener: function() {},
|
| 2128 |
-
dispatchEvent: function() { return true; }
|
| 2129 |
};
|
| 2130 |
}
|
| 2131 |
return _origMatchMedia(query);
|
| 2132 |
};
|
| 2133 |
}
|
|
|
|
|
|
|
|
|
|
| 2134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2135 |
function patchMaps() {
|
| 2136 |
document.querySelectorAll('#landing-map-plot .js-plotly-plot').forEach(function(gd) {
|
| 2137 |
if (gd._denaigeoScrollZoomPatched || !gd.data || !gd.layout || !window.Plotly) return;
|
|
@@ -2157,4 +2165,4 @@ function() {
|
|
| 2157 |
"""
|
| 2158 |
|
| 2159 |
if __name__ == "__main__":
|
| 2160 |
-
demo.launch(css=_MODERN_UI_CSS, theme=theme, js=_PAGE_LOAD_JS)
|
|
|
|
| 2100 |
|
| 2101 |
demo.queue(default_concurrency_limit=1)
|
| 2102 |
|
| 2103 |
+
# --- <head> μ μ½μ
λλ μ€ν¬λ¦½νΈ: Gradio μ± λ²λ€μ΄ λ‘λ/μ€νλκΈ° 'μ μ' μ€νλ©λλ€ ---
|
| 2104 |
+
# Gradio 6.xλ μ μ 'dark' ν΄λμ€ νλκ° μλλΌ, κ° μ»΄ν¬λνΈκ° κ°λ³μ μΌλ‘
|
| 2105 |
+
# window.matchMedia('(prefers-color-scheme: dark)') λ₯Ό μ§μ νμΈν΄μ λ€ν¬ μ€νμΌμ
|
| 2106 |
+
# μ μ©ν©λλ€. μ΄ νμΈμ μ»΄ν¬λνΈκ° μ²μ λ λλ§λ λ ν λ² μΌμ΄λλ―λ‘, demo.launch()μ
|
| 2107 |
+
# js= νλΌλ―Έν°(μ»΄ν¬λνΈκ° μ΄λ―Έ λ§μ΄νΈλ 'μ΄ν'μ μ€νλ¨)λ‘ λμ€μ matchMedia λ₯Ό
|
| 2108 |
+
# ν¨μΉνλ©΄ μ΄λ―Έ λ¦μ΅λλ€. κ·Έλμ μ΄ ν¨μΉλ head= λ‘ λ£μ΄ <head> μμ <script> λ‘
|
| 2109 |
+
# μ€νμμΌ, Gradio μ± λ²λ€μ <script> νκ·Έλ³΄λ€ λ¨Όμ (λ¬Έμ μμμ μμ΄λ―λ‘) μ€νλκ²
|
| 2110 |
+
# ν©λλ€. λ€ν¬λͺ¨λ κ΄λ ¨ μ§μμλ νμ "λ€ν¬ μλ"μ΄λΌκ³ λ΅νλλ‘ λ§λ€μ΄μ, μμ€ν
|
| 2111 |
+
# μ€μ κ³Ό 무κ΄νκ² μ΄ μ±μ νμ λΌμ΄νΈ λͺ¨λλ‘ λ λλ§λ©λλ€.
|
| 2112 |
+
_HEAD_HTML = """
|
| 2113 |
+
<script>
|
| 2114 |
+
(function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2115 |
if (window.matchMedia && !window._denaigeoMatchMediaPatched) {
|
| 2116 |
window._denaigeoMatchMediaPatched = true;
|
| 2117 |
+
var _origMatchMedia = window.matchMedia.bind(window);
|
| 2118 |
window.matchMedia = function(query) {
|
| 2119 |
if (typeof query === 'string' && query.indexOf('prefers-color-scheme') !== -1 && query.indexOf('dark') !== -1) {
|
| 2120 |
return {
|
| 2121 |
matches: false, media: query, onchange: null,
|
| 2122 |
addListener: function() {}, removeListener: function() {},
|
| 2123 |
addEventListener: function() {}, removeEventListener: function() {},
|
| 2124 |
+
dispatchEvent: function() { return true; }
|
| 2125 |
};
|
| 2126 |
}
|
| 2127 |
return _origMatchMedia(query);
|
| 2128 |
};
|
| 2129 |
}
|
| 2130 |
+
})();
|
| 2131 |
+
</script>
|
| 2132 |
+
"""
|
| 2133 |
|
| 2134 |
+
# --- νμ΄μ§ λ‘λ ν(μ»΄ν¬λνΈ λ§μ΄νΈ μ΄ν) μ€νλλ JS ---
|
| 2135 |
+
# 1) λλ© νμ΄μ§μ μΈκ³μ§λλ μ₯μμ©μ΄λΌ μ€ν¬λ‘€ ν λ‘ νλ/μΆμλ νμκ° μμ΅λλ€.
|
| 2136 |
+
# Python μͺ½μμ dragmode=False λ‘ ν΄λ¦+λλκ·Έ νλ/μ΄λμ μ΄λ―Έ λ§μκ³ , μ€ν¬λ‘€ ν
|
| 2137 |
+
# νλ(scrollZoom)λ Plotly.js μ config κ°μ΄λΌ Python figure κ°μ²΄μλ λ΄κΈ°μ§
|
| 2138 |
+
# μμΌλ―λ‘, μ¬κΈ°μ ν΄λΉ config λ₯Ό λ€μ μ μ©ν΄ λλλ€.
|
| 2139 |
+
# 2) matchMedia ν¨μΉλ μ head μ€ν¬λ¦½νΈκ° μ΄λ―Έ μ²λ¦¬νμ§λ§, νΉμλΌλ μ΄λκ°μ 'dark'
|
| 2140 |
+
# ν΄λμ€κ° λ¨μμλ κ²½μ°λ₯Ό λλΉν 보쑰 μλ¨μΌλ‘ κ³μ μ κ±°ν©λλ€.
|
| 2141 |
+
_PAGE_LOAD_JS = """
|
| 2142 |
+
function() {
|
| 2143 |
function patchMaps() {
|
| 2144 |
document.querySelectorAll('#landing-map-plot .js-plotly-plot').forEach(function(gd) {
|
| 2145 |
if (gd._denaigeoScrollZoomPatched || !gd.data || !gd.layout || !window.Plotly) return;
|
|
|
|
| 2165 |
"""
|
| 2166 |
|
| 2167 |
if __name__ == "__main__":
|
| 2168 |
+
demo.launch(css=_MODERN_UI_CSS, theme=theme, js=_PAGE_LOAD_JS, head=_HEAD_HTML)
|