Add live log viewer and enable file logging in service

This commit is contained in:
Gemini Bot
2026-01-20 13:19:06 +00:00
parent 6e2a9d5b2e
commit 507c4a10ea
4 changed files with 92 additions and 15 deletions

18
app.py
View File

@@ -24,15 +24,31 @@ def api_data():
summary = miner_api.summary()
devs = miner_api.devs()
pools = miner_api.pools()
stats = miner_api.stats()
# Process data for easier frontend consumption
data = {
'summary': summary['SUMMARY'][0] if summary and 'SUMMARY' in summary else {},
'devs': devs['DEVS'] if devs and 'DEVS' in devs else [],
'pools': pools['POOLS'] if pools and 'POOLS' in pools else []
'pools': pools['POOLS'] if pools and 'POOLS' in pools else [],
'stats': stats if stats else {}
}
return jsonify(data)
@app.route('/api/log')
def api_log():
log_path = 'cgminer.log'
if not os.path.exists(log_path):
return jsonify({'log': 'Kein Log gefunden.'})
try:
# Read last 50 lines
with open(log_path, 'r') as f:
lines = f.readlines()
return jsonify({'log': ''.join(lines[-50:])})
except Exception as e:
return jsonify({'log': f'Fehler beim Lesen des Logs: {str(e)}'})
@app.route('/save_settings', methods=['POST'])
def save_settings():
# Construct config object from form