Add live log viewer and enable file logging in service
This commit is contained in:
18
app.py
18
app.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user