|
|
|
|
@ -14,12 +14,9 @@ PORT = 8443
@@ -14,12 +14,9 @@ PORT = 8443
|
|
|
|
|
|
|
|
|
|
def generate_certificate(): |
|
|
|
|
"""Génère un certificat auto-signé si nécessaire""" |
|
|
|
|
cert_file = 'cert.pem' |
|
|
|
|
key_file = 'key.pem' |
|
|
|
|
|
|
|
|
|
if os.path.exists(cert_file) and os.path.exists(key_file): |
|
|
|
|
print('✓ Certificats existants trouvés') |
|
|
|
|
return cert_file, key_file |
|
|
|
|
script_dir = os.path.dirname(os.path.abspath(__file__)) |
|
|
|
|
cert_file = os.path.join(script_dir, 'cert.pem') |
|
|
|
|
key_file = os.path.join(script_dir, 'key.pem') |
|
|
|
|
|
|
|
|
|
print('Génération d\'un certificat auto-signé...') |
|
|
|
|
try: |
|
|
|
|
@ -38,10 +35,20 @@ def generate_certificate():
@@ -38,10 +35,20 @@ def generate_certificate():
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
try: |
|
|
|
|
cert_file, key_file = generate_certificate() |
|
|
|
|
# Les certificats sont à la racine du projet |
|
|
|
|
cert_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'cert.pem') |
|
|
|
|
key_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'key.pem') |
|
|
|
|
|
|
|
|
|
# Générer si nécessaire |
|
|
|
|
if not os.path.exists(cert_file) or not os.path.exists(key_file): |
|
|
|
|
generate_certificate() |
|
|
|
|
else: |
|
|
|
|
print('✓ Certificats existants trouvés') |
|
|
|
|
|
|
|
|
|
# Changer vers le répertoire du script |
|
|
|
|
os.chdir(os.path.dirname(os.path.abspath(__file__))) |
|
|
|
|
# Changer vers le répertoire html |
|
|
|
|
script_dir = os.path.dirname(os.path.abspath(__file__)) |
|
|
|
|
html_dir = os.path.join(script_dir, 'html') |
|
|
|
|
os.chdir(html_dir) |
|
|
|
|
|
|
|
|
|
# Créer le serveur HTTP |
|
|
|
|
handler = http.server.SimpleHTTPRequestHandler |
|
|
|
|
|