Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -756,8 +756,8 @@ async def root(request: Request):
|
|
| 756 |
try:
|
| 757 |
with open("app.log", "r") as f:
|
| 758 |
lines = f.readlines()
|
| 759 |
-
# Show
|
| 760 |
-
log_content = "".join(lines
|
| 761 |
# Escape HTML
|
| 762 |
log_content = log_content.replace("&", "&").replace("<", "<").replace(">", ">")
|
| 763 |
except Exception as e:
|
|
@@ -926,21 +926,21 @@ async def root(request: Request):
|
|
| 926 |
</div>
|
| 927 |
|
| 928 |
<div class="tabs">
|
| 929 |
-
<button class="tab-btn active" onclick="switchTab('
|
| 930 |
<button class="tab-btn" onclick="switchTab('assistant')">π€ Assistant</button>
|
| 931 |
-
<button class="tab-btn" onclick="switchTab('
|
| 932 |
</div>
|
| 933 |
|
| 934 |
-
<div id="
|
| 935 |
-
<
|
| 936 |
</div>
|
| 937 |
-
|
| 938 |
<div id="assistant" class="tab-content">
|
| 939 |
<pre class="code-block" id="assistant-json">{assistant_json}</pre>
|
| 940 |
</div>
|
| 941 |
|
| 942 |
-
<div id="
|
| 943 |
-
<
|
| 944 |
</div>
|
| 945 |
|
| 946 |
<p class="footer">Cloud Notifier Interface</p>
|
|
@@ -987,13 +987,18 @@ async def root(request: Request):
|
|
| 987 |
// Apply highlighting on load
|
| 988 |
document.getElementById('health-json').innerHTML = syntaxHighlight(document.getElementById('health-json').innerText);
|
| 989 |
document.getElementById('assistant-json').innerHTML = syntaxHighlight(document.getElementById('assistant-json').innerText);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 990 |
</script>
|
| 991 |
</body>
|
| 992 |
</html>
|
| 993 |
-
"""
|
| 994 |
-
|
| 995 |
-
|
| 996 |
-
@app.get("/assistant")
|
| 997 |
async def internal_assistant():
|
| 998 |
load_dotenv(override=True)
|
| 999 |
|
|
|
|
| 756 |
try:
|
| 757 |
with open("app.log", "r") as f:
|
| 758 |
lines = f.readlines()
|
| 759 |
+
# Show all lines
|
| 760 |
+
log_content = "".join(lines)
|
| 761 |
# Escape HTML
|
| 762 |
log_content = log_content.replace("&", "&").replace("<", "<").replace(">", ">")
|
| 763 |
except Exception as e:
|
|
|
|
| 926 |
</div>
|
| 927 |
|
| 928 |
<div class="tabs">
|
| 929 |
+
<button class="tab-btn active" onclick="switchTab('logs')">π Logs</button>
|
| 930 |
<button class="tab-btn" onclick="switchTab('assistant')">π€ Assistant</button>
|
| 931 |
+
<button class="tab-btn" onclick="switchTab('health')">π₯ Health</button>
|
| 932 |
</div>
|
| 933 |
|
| 934 |
+
<div id="logs" class="tab-content active">
|
| 935 |
+
<div class="log-container" id="log-container-view">{log_content}</div>
|
| 936 |
</div>
|
| 937 |
+
|
| 938 |
<div id="assistant" class="tab-content">
|
| 939 |
<pre class="code-block" id="assistant-json">{assistant_json}</pre>
|
| 940 |
</div>
|
| 941 |
|
| 942 |
+
<div id="health" class="tab-content">
|
| 943 |
+
<pre class="code-block" id="health-json">{health_json}</pre>
|
| 944 |
</div>
|
| 945 |
|
| 946 |
<p class="footer">Cloud Notifier Interface</p>
|
|
|
|
| 987 |
// Apply highlighting on load
|
| 988 |
document.getElementById('health-json').innerHTML = syntaxHighlight(document.getElementById('health-json').innerText);
|
| 989 |
document.getElementById('assistant-json').innerHTML = syntaxHighlight(document.getElementById('assistant-json').innerText);
|
| 990 |
+
|
| 991 |
+
// Auto-scroll logs on initial load since it's the default active tab
|
| 992 |
+
window.onload = function() {{
|
| 993 |
+
var logContainer = document.getElementById('log-container-view');
|
| 994 |
+
if (logContainer) {{
|
| 995 |
+
logContainer.scrollTop = logContainer.scrollHeight;
|
| 996 |
+
}}
|
| 997 |
+
}};
|
| 998 |
</script>
|
| 999 |
</body>
|
| 1000 |
</html>
|
| 1001 |
+
""".replace("{{log_content}}", log_content)
|
|
|
|
|
|
|
|
|
|
| 1002 |
async def internal_assistant():
|
| 1003 |
load_dotenv(override=True)
|
| 1004 |
|