
- Ajout endpoint manquant /api/notary/document/{id}/status - Correction erreur BrokenPipeError dans le serveur web - Création de ressources CSS/JS locales pour éviter les erreurs DNS - Bootstrap CSS minimal local (bootstrap.min.css) - Chart.js minimal local (chart.min.js) - Font Awesome minimal local (fontawesome.min.css) - Gestion d'erreurs de connexion fermée par le client - Interface web fonctionnelle sans dépendances externes - Aperçu PDF avec PDF.js fonctionnel - Polling de statut des documents opérationnel
80 lines
2.7 KiB
Python
Executable File
80 lines
2.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Serveur web simple pour l'interface 4NK Notariat
|
|
"""
|
|
import http.server
|
|
import socketserver
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
def start_web_server(port=8080):
|
|
"""Démarre le serveur web pour l'interface"""
|
|
|
|
# Répertoire de l'interface web
|
|
web_dir = Path(__file__).parent
|
|
|
|
# Changement vers le répertoire web
|
|
os.chdir(web_dir)
|
|
|
|
# Configuration du serveur avec gestion du favicon
|
|
class CustomHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
|
|
def end_headers(self):
|
|
# Ajouter des headers pour éviter le cache du favicon
|
|
if self.path == '/favicon.ico':
|
|
self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate')
|
|
self.send_header('Pragma', 'no-cache')
|
|
self.send_header('Expires', '0')
|
|
super().end_headers()
|
|
|
|
def do_GET(self):
|
|
try:
|
|
# Gérer le favicon.ico
|
|
if self.path == '/favicon.ico':
|
|
self.send_response(200)
|
|
self.send_header('Content-type', 'image/svg+xml')
|
|
self.end_headers()
|
|
favicon_svg = '''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
|
<text y=".9em" font-size="90">📄</text>
|
|
</svg>'''
|
|
self.wfile.write(favicon_svg.encode())
|
|
return
|
|
super().do_GET()
|
|
except (BrokenPipeError, ConnectionResetError):
|
|
# Ignorer les erreurs de connexion fermée par le client
|
|
pass
|
|
|
|
handler = CustomHTTPRequestHandler
|
|
|
|
try:
|
|
with socketserver.TCPServer(("", port), handler) as httpd:
|
|
print(f"🌐 Interface web 4NK Notariat démarrée sur http://localhost:{port}")
|
|
print(f"📁 Répertoire: {web_dir}")
|
|
print("🔄 Appuyez sur Ctrl+C pour arrêter")
|
|
print()
|
|
|
|
httpd.serve_forever()
|
|
|
|
except KeyboardInterrupt:
|
|
print("\n🛑 Arrêt du serveur web")
|
|
sys.exit(0)
|
|
except OSError as e:
|
|
if e.errno == 98: # Address already in use
|
|
print(f"❌ Erreur: Le port {port} est déjà utilisé")
|
|
print(f"💡 Essayez un autre port: python start_web.py {port + 1}")
|
|
else:
|
|
print(f"❌ Erreur: {e}")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
# Port par défaut ou port spécifié en argument
|
|
port = 8080
|
|
if len(sys.argv) > 1:
|
|
try:
|
|
port = int(sys.argv[1])
|
|
except ValueError:
|
|
print("❌ Erreur: Le port doit être un nombre")
|
|
sys.exit(1)
|
|
|
|
start_web_server(port)
|