27 lines
822 B
Python
27 lines
822 B
Python
import os
|
|
from flask import Blueprint, redirect, flash, send_file, abort
|
|
from auth import require_level
|
|
from config_utils import CONFIGS_DIR
|
|
|
|
bp = Blueprint('action_clear_ddns_log', __name__)
|
|
|
|
LOG_FILE = f'{CONFIGS_DIR}/ddns.log'
|
|
|
|
|
|
@bp.route('/action/clear_ddns_log', methods=['POST'])
|
|
@require_level('administrator')
|
|
def clear_ddns_log():
|
|
try:
|
|
open(LOG_FILE, 'w').close()
|
|
flash('DDNS log cleared.', 'success')
|
|
except Exception as ex:
|
|
flash(f'Could not clear log: {ex}', 'error')
|
|
return redirect('/view/view_ddns')
|
|
|
|
|
|
@bp.route('/action/download_ddns_log', methods=['GET'])
|
|
@require_level('administrator')
|
|
def download_ddns_log():
|
|
if not os.path.isfile(LOG_FILE):
|
|
abort(404)
|
|
return send_file(LOG_FILE, as_attachment=True, download_name='ddns.log', mimetype='text/plain')
|