improvements
This commit is contained in:
parent
a7c7481d24
commit
de5a2a189b
11
app.py
11
app.py
@ -1,7 +1,12 @@
|
|||||||
|
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
|
import eventlet
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
from flask import Flask, render_template, send_file, url_for, jsonify, request, session, send_from_directory, make_response, abort
|
from flask import Flask, render_template, send_file, url_for, jsonify, request, session, send_from_directory, make_response, abort
|
||||||
import os
|
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
import io
|
import io
|
||||||
from functools import wraps
|
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['SECRET_KEY'] = app_config['SECRET_KEY']
|
||||||
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=90)
|
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_SAMESITE'] = 'None'
|
||||||
app.config['SESSION_COOKIE_SECURE'] = True
|
app.config['SESSION_COOKIE_SECURE'] = True
|
||||||
|
|
||||||
@ -69,7 +74,7 @@ allowed_domains = re.findall(pattern, host_rule)
|
|||||||
|
|
||||||
socketio = SocketIO(
|
socketio = SocketIO(
|
||||||
app,
|
app,
|
||||||
async_mode='eventlet',
|
async_mode='eventlet' if FLASK_ENV == 'production' else 'threading',
|
||||||
cors_allowed_origins=allowed_domains
|
cors_allowed_origins=allowed_domains
|
||||||
)
|
)
|
||||||
background_thread_running = False
|
background_thread_running = False
|
||||||
|
|||||||
@ -16,7 +16,8 @@ services:
|
|||||||
propagation: rshared
|
propagation: rshared
|
||||||
environment:
|
environment:
|
||||||
- FLASK_APP=app.py
|
- FLASK_APP=app.py
|
||||||
- FLASK_ENV=production
|
- FLASK_ENV=development
|
||||||
|
- FLASK_DEBUG=1
|
||||||
networks:
|
networks:
|
||||||
- traefik
|
- traefik
|
||||||
labels:
|
labels:
|
||||||
@ -37,10 +38,10 @@ services:
|
|||||||
# Internal port
|
# Internal port
|
||||||
- "traefik.http.services.${CONTAINER_NAME}.loadbalancer.server.port=5000"
|
- "traefik.http.services.${CONTAINER_NAME}.loadbalancer.server.port=5000"
|
||||||
|
|
||||||
# Production-ready Gunicorn command with eventlet
|
# Dev server with autoreload for live code changes
|
||||||
command: >
|
command: >
|
||||||
sh -c "pip install -r requirements.txt &&
|
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:
|
networks:
|
||||||
|
|||||||
@ -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>`;
|
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>';
|
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)
|
// Render files (including music and non-image files)
|
||||||
currentMusicFiles = [];
|
currentMusicFiles = [];
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
height: 85vh;
|
height: 85vh;
|
||||||
padding: 20px;
|
|
||||||
}
|
}
|
||||||
.map-section {
|
.map-section {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -39,6 +38,9 @@
|
|||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
.page-content {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
.stats {
|
.stats {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
@ -94,11 +96,9 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="split-view">
|
<div class="page-content">
|
||||||
<!-- Map Section -->
|
|
||||||
<div class="map-section">
|
|
||||||
<div class="section-header">
|
<div class="section-header">
|
||||||
<h2 style="margin: 0 0 10px 0;">Live Connection Map</h2>
|
<h2 style="margin: 0;">Verbindungen der letzten 10 Minuten</h2>
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
<div class="stat-item">
|
<div class="stat-item">
|
||||||
<div class="stat-label">Active Dots</div>
|
<div class="stat-label">Active Dots</div>
|
||||||
@ -108,22 +108,21 @@
|
|||||||
<div class="stat-label">Last Connection</div>
|
<div class="stat-label">Last Connection</div>
|
||||||
<div class="stat-value" id="last-connection" style="font-size: 14px;">-</div>
|
<div class="stat-value" id="last-connection" style="font-size: 14px;">-</div>
|
||||||
</div>
|
</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-item">
|
||||||
<div class="stat-label">Total Connections</div>
|
<div class="stat-label">Total Connections</div>
|
||||||
<div class="stat-value" id="totalConnections">0</div>
|
<div class="stat-value" id="totalConnections">0</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="split-view">
|
||||||
|
<!-- Map Section -->
|
||||||
|
<div class="map-section">
|
||||||
|
<div id="map"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Table Section -->
|
||||||
|
<div class="table-section">
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead class="table-secondary">
|
<thead class="table-secondary">
|
||||||
@ -144,6 +143,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user