modified: app.py

modified:   templates/logs.html
This commit is contained in:
SimolZimol
2024-09-03 13:09:19 +02:00
parent 764f4832cd
commit 2748b7583e
2 changed files with 48 additions and 22 deletions

View File

@@ -5,34 +5,31 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bot Logs</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.3/socket.io.min.js"></script>
</head>
<body>
<div class="container mt-5">
<h1 class="text-center">Bot Logs</h1>
<div class="mt-4">
<h3>Live Logs</h3>
<pre id="live-logs" class="bg-dark text-light p-3" style="height: 300px; overflow-y: scroll;"></pre>
<div class="card mt-4">
<div class="card-body">
<button class="btn btn-primary mb-3" onclick="refreshLogs()">Refresh Logs</button>
<a href="{{ url_for('download_logs') }}" class="btn btn-secondary mb-3">Download Logs</a>
<pre id="log-content" style="height: 500px; overflow-y: scroll; background-color: #f8f9fa; padding: 10px; border: 1px solid #ddd;"></pre>
<a href="{{ url_for('index') }}" class="btn btn-secondary btn-block mt-3">Back to Dashboard</a>
</div>
</div>
<div class="mt-4">
<h3>Log Files</h3>
<ul class="list-group">
{% for log_file in log_files %}
<li class="list-group-item">
<a href="{{ url_for('view_log', log_file=log_file) }}">{{ log_file }}</a>
</li>
{% endfor %}
</ul>
</div>
<a href="{{ url_for('index') }}" class="btn btn-secondary btn-block mt-3">Back to Dashboard</a>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
var socket = io();
socket.on('log', function(msg) {
var logs = document.getElementById('live-logs');
logs.innerHTML += msg.data + '\n';
logs.scrollTop = logs.scrollHeight;
});
function refreshLogs() {
fetch('{{ url_for("get_logs") }}')
.then(response => response.json())
.then(data => {
document.getElementById("log-content").textContent = data.logs;
});
}
window.onload = refreshLogs;
</script>
</body>
</html>