improvements

This commit is contained in:
lelo 2025-12-14 10:28:34 +00:00
parent a7c7481d24
commit de5a2a189b
4 changed files with 61 additions and 54 deletions

15
app.py
View File

@ -1,7 +1,12 @@
import eventlet
eventlet.monkey_patch()
from flask import Flask, render_template, send_file, url_for, jsonify, request, session, send_from_directory, make_response, abort
import os
# Use eventlet only in production; keep dev on threading to avoid monkey_patch issues with reloader
FLASK_ENV = os.environ.get('FLASK_ENV', 'production')
if FLASK_ENV == 'production':
import eventlet
eventlet.monkey_patch()
from flask import Flask, render_template, send_file, url_for, jsonify, request, session, send_from_directory, make_response, abort
from PIL import Image, ImageOps
import io
from functools import wraps
@ -40,7 +45,7 @@ app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1)
app.config['SECRET_KEY'] = app_config['SECRET_KEY']
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=90)
if os.environ.get('FLASK_ENV') == 'production':
if FLASK_ENV == 'production':
app.config['SESSION_COOKIE_SAMESITE'] = 'None'
app.config['SESSION_COOKIE_SECURE'] = True
@ -69,7 +74,7 @@ allowed_domains = re.findall(pattern, host_rule)
socketio = SocketIO(
app,
async_mode='eventlet',
async_mode='eventlet' if FLASK_ENV == 'production' else 'threading',
cors_allowed_origins=allowed_domains
)
background_thread_running = False

View File

@ -16,7 +16,8 @@ services:
propagation: rshared
environment:
- FLASK_APP=app.py
- FLASK_ENV=production
- FLASK_ENV=development
- FLASK_DEBUG=1
networks:
- traefik
labels:
@ -37,10 +38,10 @@ services:
# Internal port
- "traefik.http.services.${CONTAINER_NAME}.loadbalancer.server.port=5000"
# Production-ready Gunicorn command with eventlet
# Dev server with autoreload for live code changes
command: >
sh -c "pip install -r requirements.txt &&
gunicorn --worker-class eventlet -w 1 -b 0.0.0.0:5000 app:app"
flask run --host=0.0.0.0 --port=5000 --reload"
networks:

View File

@ -128,12 +128,13 @@ function renderContent(data) {
}
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="${dir.path}">${link_symbol} ${dir.name}</a>${share_link}</li>`;
});
if (data.breadcrumbs.length === 1) {
contentHTML += `<li class="link-item" onclick="viewSearch()"><a onclick="viewSearch() class="link-link">🔎 Suche</a></li>`;
}
contentHTML += '</ul>';
}
}
// Add search link at top level above directories/files
if (data.breadcrumbs.length === 1) {
contentHTML = `<ul><li class="link-item" onclick="viewSearch()"><a onclick="viewSearch()" class="link-link">🔎 Suche</a></li></ul>` + contentHTML;
}
// Render files (including music and non-image files)
currentMusicFiles = [];

View File

@ -12,7 +12,6 @@
display: flex;
gap: 20px;
height: 85vh;
padding: 20px;
}
.map-section {
flex: 1;
@ -39,6 +38,9 @@
margin-bottom: 15px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.page-content {
padding: 20px;
}
.stats {
display: flex;
gap: 20px;
@ -94,53 +96,51 @@
{% endblock %}
{% block content %}
<div class="split-view">
<!-- Map Section -->
<div class="map-section">
<div class="section-header">
<h2 style="margin: 0 0 10px 0;">Live Connection Map</h2>
<div class="stats">
<div class="stat-item">
<div class="stat-label">Active Dots</div>
<div class="stat-value" id="active-dots">0</div>
</div>
<div class="stat-item">
<div class="stat-label">Last Connection</div>
<div class="stat-value" id="last-connection" style="font-size: 14px;">-</div>
</div>
<div class="page-content">
<div class="section-header">
<h2 style="margin: 0;">Verbindungen der letzten 10 Minuten</h2>
<div class="stats">
<div class="stat-item">
<div class="stat-label">Active Dots</div>
<div class="stat-value" id="active-dots">0</div>
</div>
<div class="stat-item">
<div class="stat-label">Last Connection</div>
<div class="stat-value" id="last-connection" style="font-size: 14px;">-</div>
</div>
<div class="stat-item">
<div class="stat-label">Total Connections</div>
<div class="stat-value" id="totalConnections">0</div>
</div>
</div>
<div id="map"></div>
</div>
<!-- Table Section -->
<div class="table-section">
<div class="section-header">
<h2 style="margin: 0;">Verbindungen der letzten 10 Minuten</h2>
<div class="stats">
<div class="stat-item">
<div class="stat-label">Total Connections</div>
<div class="stat-value" id="totalConnections">0</div>
</div>
</div>
<div class="split-view">
<!-- Map Section -->
<div class="map-section">
<div id="map"></div>
</div>
<div class="table-container">
<table class="table table-hover">
<thead class="table-secondary">
<tr>
<th>Timestamp</th>
<th>Location</th>
<th>User Agent</th>
<th>File Path</th>
<th>File Size</th>
<th>MIME-Typ</th>
<th>Cached</th>
</tr>
</thead>
<tbody id="connectionsTableBody">
{# dynamically populated via Socket.IO #}
</tbody>
</table>
<!-- Table Section -->
<div class="table-section">
<div class="table-container">
<table class="table table-hover">
<thead class="table-secondary">
<tr>
<th>Timestamp</th>
<th>Location</th>
<th>User Agent</th>
<th>File Path</th>
<th>File Size</th>
<th>MIME-Typ</th>
<th>Cached</th>
</tr>
</thead>
<tbody id="connectionsTableBody">
{# dynamically populated via Socket.IO #}
</tbody>
</table>
</div>
</div>
</div>
</div>