CREATED RESURSE FOLDER

This commit is contained in:
Ske087
2025-02-01 21:13:08 +02:00
parent 28aa743947
commit 85a23eeca8
7 changed files with 14 additions and 11 deletions

17
app.py
View File

@@ -22,10 +22,13 @@ bcrypt = Bcrypt(app)
UPLOAD_FOLDER = 'static/uploads'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
UPLOAD_FOLDERLOGO = 'static/resurse'
app.config['UPLOAD_FOLDERLOGO'] = UPLOAD_FOLDERLOGO
# Ensure the upload folder exists
if not os.path.exists(UPLOAD_FOLDER):
os.makedirs(UPLOAD_FOLDER)
os.makedirs(UPLOAD_FOLDERLOGO)
login_manager = LoginManager(app)
login_manager.login_view = 'login'
@@ -84,7 +87,7 @@ def convert_ppt_to_pdf(input_file, output_file):
def dashboard():
players = Player.query.all()
groups = Group.query.all()
logo_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], 'logo.png'))
logo_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDERLOGO'], 'logo.png'))
return render_template('dashboard.html', players=players, groups=groups, logo_exists=logo_exists)
@app.route('/register', methods=['GET', 'POST'])
@@ -111,7 +114,7 @@ def login():
else:
flash('Login Unsuccessful. Please check username and password', 'danger')
login_picture_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], 'login_picture.png'))
login_picture_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDERLOGO'], 'login_picture.png'))
return render_template('login.html', login_picture_exists=login_picture_exists)
@app.route('/logout')
@@ -180,8 +183,8 @@ def upload_content():
@login_required
@admin_required
def admin():
logo_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], 'logo.png'))
login_picture_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], 'login_picture.png'))
logo_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDERLOGO'], 'logo.png'))
login_picture_exists = os.path.exists(os.path.join(app.config['UPLOAD_FOLDERLOGO'], 'login_picture.png'))
users = User.query.all()
return render_template('admin.html', users=users, logo_exists=logo_exists, login_picture_exists=login_picture_exists)
@@ -449,7 +452,7 @@ def upload_logo():
if file:
filename = secure_filename(file.filename)
file_path = os.path.join(app.config['UPLOAD_FOLDER'], 'logo.png')
file_path = os.path.join(app.config['UPLOAD_FOLDERLOGO'], 'logo.png')
file.save(file_path)
return redirect(url_for('admin'))
@@ -462,12 +465,12 @@ def upload_personalization_pictures():
if logo_file and logo_file.filename != '':
logo_filename = secure_filename(logo_file.filename)
logo_file_path = os.path.join(app.config['UPLOAD_FOLDER'], 'logo.png')
logo_file_path = os.path.join(app.config['UPLOAD_FOLDERLOGO'], 'logo.png')
logo_file.save(logo_file_path)
if login_picture_file and login_picture_file.filename != '':
login_picture_filename = secure_filename(login_picture_file.filename)
login_picture_file_path = os.path.join(app.config['UPLOAD_FOLDER'], 'login_picture.png')
login_picture_file_path = os.path.join(app.config['UPLOAD_FOLDERLOGO'], 'login_picture.png')
login_picture_file.save(login_picture_file_path)
return redirect(url_for('admin'))