pywallter/views/logs.py

33 lines
1.1 KiB
Python
Raw Permalink Normal View History

2023-11-02 08:03:21 +01:00
from flask import Blueprint, Flask, request, flash, render_template, url_for, session, redirect, abort, make_response, send_file
2020-11-29 02:05:19 +01:00
import glob, os, sys
2023-11-02 08:03:21 +01:00
from markupsafe import escape
2020-11-29 02:05:19 +01:00
logs = Blueprint('logs', __name__, template_folder='templates')
2022-08-06 18:22:24 +02:00
app = Flask( 'pywallter' )
app.config.from_pyfile('config.py')
#### Variables ####################################################################################
DOSSIER_PERSO= app.config['DOSSIER_APP']
extensionimg = app.config['EXT_IMG']
DATABASE = app.config['DATABASE']
##################################################################################################
2020-11-29 02:05:19 +01:00
@logs.route('/logs/')
def logfile():
2022-08-06 18:22:24 +02:00
if 'username' in session:
UTILISATEUR='%s'% escape(session['username'])
log_file=os.path.join(DOSSIER_PERSO, UTILISATEUR, "log.txt")
with open(log_file, 'r') as log:
print("on passe ici")
2020-11-29 02:05:19 +01:00
logs=log.readlines()
log.close()
2022-08-06 18:22:24 +02:00
return render_template('logs.html', section="Logs", logs=logs)
2020-11-29 02:05:19 +01:00
else :
2022-08-06 18:22:24 +02:00
return redirect(url_for('loginlogout.login', _external=True), code=401)