feat: Fehlerbehandlung für WiFi-Verbindungen verbessert und Fallback-AP-Start optimiert; Versionsnummer auf 1.0.77 erhöht
This commit is contained in:
31
app.py
31
app.py
@@ -1,14 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
"""PiCopy v2 - USB Copy Service mit WiFi-Fallback AP"""
|
||||
|
||||
import traceback
|
||||
import urllib.request as _urlreq
|
||||
from pathlib import Path
|
||||
|
||||
from flask import Flask, render_template, send_file
|
||||
from flask import Flask, render_template, send_file, jsonify
|
||||
|
||||
from picopy.config import VERSION, BASE_DIR, RAW_BASE
|
||||
from picopy.config import VERSION, BASE_DIR, RAW_BASE, log
|
||||
|
||||
# Absoluter Pfad zum templates/-Verzeichnis, unabhängig vom Arbeitsverzeichnis
|
||||
_HERE = Path(__file__).parent
|
||||
app = Flask(__name__, template_folder=str(_HERE / 'templates'))
|
||||
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
def _handle_exception(e):
|
||||
log.error('Unbehandelter Fehler:\n' + traceback.format_exc())
|
||||
return jsonify(error=str(e)), 500
|
||||
|
||||
app = Flask(__name__, template_folder='templates')
|
||||
|
||||
from routes import register_routes
|
||||
register_routes(app)
|
||||
@@ -49,14 +59,21 @@ if __name__ == '__main__':
|
||||
from picopy.wifi import wifi_monitor
|
||||
from picopy.wireguard import wg_monitor
|
||||
from picopy.system import update_check_loop
|
||||
from picopy.config import log, load_cfg
|
||||
from picopy.config import load_cfg
|
||||
|
||||
# Startprüfung: Template vorhanden?
|
||||
tmpl = _HERE / 'templates' / 'index.html'
|
||||
if not tmpl.exists():
|
||||
log.error(f'FEHLER: Template nicht gefunden: {tmpl}')
|
||||
else:
|
||||
log.info(f'Template gefunden: {tmpl}')
|
||||
|
||||
cleanup_stale_mounts()
|
||||
load_state()
|
||||
wg_update_state()
|
||||
threading.Thread(target=usb_monitor, daemon=True).start()
|
||||
threading.Thread(target=wifi_monitor, daemon=True).start()
|
||||
threading.Thread(target=wg_monitor, daemon=True).start()
|
||||
threading.Thread(target=usb_monitor, daemon=True).start()
|
||||
threading.Thread(target=wifi_monitor, daemon=True).start()
|
||||
threading.Thread(target=wg_monitor, daemon=True).start()
|
||||
threading.Thread(target=update_check_loop, daemon=True).start()
|
||||
if load_cfg().get('wireguard_auto') and WG_CONF.exists():
|
||||
threading.Thread(target=wg_connect, daemon=True).start()
|
||||
|
||||
Reference in New Issue
Block a user