puh current config pre departure

This commit is contained in:
2025-08-03 17:18:58 -07:00
parent 55560dfcb2
commit 05cb47761a
17 changed files with 276 additions and 91 deletions

View File

@ -1,85 +0,0 @@
import subprocess
import requests
from lxml import html
from flask import Flask, request, jsonify
import json
app = Flask(__name__)
def start_service():
command = "systemctl start timelapse.service"
try:
# Run the command using subprocess.run()
process = subprocess.Popen(command, shell=True)
except subprocess.CalledProcessError as e:
return {"Error": e.strip('\n')}
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2- | cut -b 2-"
try:
# Run the command using subprocess.run()
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
return {"Message": result.stdout.strip('\n')}
except subprocess.CalledProcessError as e:
return {"Error": e.strip('\n')}
def stop_service():
command = "systemctl stop timelapse.service"
try:
# Run the command using subprocess.run()
process = subprocess.Popen(command, shell=True)
except subprocess.CalledProcessError as e:
return {"Error": e.strip('\n')}
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2- | cut -b 2-"
try:
# Run the command using subprocess.run()
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
return {"Message": result.stdout.strip('\n')}
except subprocess.CalledProcessError as e:
return {"Error": e.strip('\n')}
def service_status():
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2- | cut -b 2-"
try:
# Run the command using subprocess.run()
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
command = "systemctl status timelapse.service | grep Active | cut -d ':' -f 2 | cut -d ' ' -f 2"
status = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
return {"Message": result.stdout.strip('\n'), "Status": status.stdout.strip('\n')}
except subprocess.CalledProcessError as e:
return {"Error": e.strip('\n')}
@app.route('/start', methods=['GET'])
def start():
try:
return jsonify(start_service())
except ValueError as e:
print(e)
return jsonify({'error': e}), 400
@app.route('/stop', methods=['GET'])
def stop():
try:
return jsonify(stop_service())
except ValueError as e:
print(e)
return jsonify({'error': e}), 400
@app.route('/status', methods=['GET'])
def status():
try:
return jsonify(service_status())
except ValueError as e:
print(e)
return jsonify({'error': e}), 400
@app.route('/test', methods=['GET'])
def test():
return jsonify({'message': 'Hello there'})
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)

View File

@ -74,6 +74,11 @@ button:hover {
background: radial-gradient(circle, #003699 0%, #337aff 100%);
color: #bdc3c7; /* Dimmer text color */
}
.deactivating {
background-color: #0d2b2c;
background: radial-gradient(circle, #0d2b2c 0%, #123738 100%);
color: #bdc3c7; /* Dimmer text color */
}
.unknown {
background-color: #ec701e;
background: radial-gradient(circle, #c9580d 0%, #ec701e 100%);