untitled1176 commited on
Commit
8d0a95f
·
verified ·
1 Parent(s): 7ccc57f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import socket
 
2
  from flask import Flask, render_template_string, request, session, redirect, url_for
3
- from wakeonlan import send_magic_packet
4
  from mcstatus import JavaServer
5
 
6
  app = Flask(__name__)
@@ -14,21 +14,24 @@ MC_PORT = 25565
14
  IMAGE_FOND = "https://images.alphacoders.com/132/1327533.png"
15
 
16
  IMAGES_GALERIE = [
17
- "https://i.redd.it/ag4307hy62qe1.jpeg",
18
- "https://pbs.twimg.com/profile_images/1627794683362480129/3xUrVnUY_400x400.jpg",
19
- "https://sativa.fr/wp-content/uploads/SnoopDogg.jpg",
20
- "https://s.yimg.com/ny/api/res/1.2/7OIT.QOoe256UkTdaHDxIw--/YXBwaWQ9aGlnaGxhbmRlcjt3PTk2MDtoPTQwMDtjZj13ZWJw/https://media.zenfs.com/fr_FR/News/Gameblog/kate-upton-gta-v.jpg",
21
- "https://i1.sndcdn.com/artworks-000148945005-hx6vn7-t1080x1080.jpg",
22
- "https://www.shutterstock.com/image-illustration/internet-meme-stupid-troll-face-260nw-201587906.jpg",
23
- "https://www.lycee3vallees.fr/wp-content/uploads/2024/08/Logo-Pole-emploi.png",
24
- "https://img.freepik.com/photos-gratuite/belle-photo-chaton-british-shorthair-blanc_181624-57681.jpg",
25
  "https://img.freepik.com/photos-premium/mignon-petit-chaton-britannique-bleu-gris-dormant-enveloppe-dans-couverture-carreaux-blanche-concept-adorables-animaux-compagnie_106368-4291.jpg",
26
- "https://images.eatself.com/811/38179_10273994.png",
27
- "https://miro.medium.com/0*Ug2qG0Ph4JkU5pEZ.png",
 
 
 
 
 
 
 
 
28
  "https://www.radiofrance.fr/s3/cruiser-production/2019/10/2ccb44bb-6211-4340-b063-4d7a015575d4/1200x680_kaaris-or-noir.jpg_or_noir.jpg",
29
- "https://i.ebayimg.com/images/g/jagAAOxyu1BTj-fx/s-l1200.jpg",
30
- "https://www.radiofrance.fr/s3/cruiser-production-eu3/2019/06/d12bbc34-45f9-4b03-b762-25ae9988b888/640x340_gettyimages-624736982.jpg",
31
- "https://upload.wikimedia.org/wikipedia/fr/b/b2/Minecraft%2C_le_film.png",
32
  ]
33
 
34
  def get_server_status():
@@ -143,16 +146,16 @@ def login():
143
  @app.route('/wake', methods=['POST'])
144
  def wake():
145
  if not session.get('auth'): return redirect('/')
146
- msg = "Échec de l'envoi"
 
 
 
147
  try:
148
- target_ip = socket.gethostbyname(MON_HOST_NOIP)
149
- # On tente l'envoi via l'IP résolue
150
- send_magic_packet(MAC_ADRESSE, ip_address=target_ip, port=9)
151
- # On tente AUSSI le broadcast par sécurité
152
- send_magic_packet(MAC_ADRESSE, ip_address="255.255.255.255", port=9)
153
- msg = "Paquet envoyé !"
154
  except Exception as e:
155
- msg = f"Erreur : {str(e)}"
156
 
157
  status_text, status_color = get_server_status()
158
  return render_template_string(HTML_TEMPLATE, logged_in=True, status_text=status_text,
 
1
  import socket
2
+ import requests
3
  from flask import Flask, render_template_string, request, session, redirect, url_for
 
4
  from mcstatus import JavaServer
5
 
6
  app = Flask(__name__)
 
14
  IMAGE_FOND = "https://images.alphacoders.com/132/1327533.png"
15
 
16
  IMAGES_GALERIE = [
17
+ "https://i.redd.it/ag4307hy62qe1.jpeg", "https://pbs.twimg.com/profile_images/1627794683362480129/3xUrVnUY_400x400.jpg",
18
+ "https://sativa.fr/wp-content/uploads/SnoopDogg.jpg", "https://media.zenfs.com/fr_FR/News/Gameblog/kate-upton-gta-v.jpg",
19
+ "https://i1.sndcdn.com/artworks-000148945005-hx6vn7-t1080x1080.jpg", "https://www.shutterstock.com/image-illustration/internet-meme-stupid-troll-face-260nw-201587906.jpg",
20
+ "https://www.lycee3vallees.fr/wp-content/uploads/2024/08/Logo-Pole-emploi.png", "https://img.freepik.com/photos-gratuite/belle-photo-chaton-british-shorthair-blanc_181624-57681.jpg",
 
 
 
 
21
  "https://img.freepik.com/photos-premium/mignon-petit-chaton-britannique-bleu-gris-dormant-enveloppe-dans-couverture-carreaux-blanche-concept-adorables-animaux-compagnie_106368-4291.jpg",
22
+ "https://images.eatself.com/811/38179_10273994.png", "https://miro.medium.com/0*Ug2qG0Ph4JkU5pEZ.png",
23
+ "https://storage.googleapis.com/pod_public/1300/245798.jpg", "https://www.nextplz.fr/wp-content/uploads/nextplz/2018/05/18068280901060695.jpg",
24
+ "https://passed.fr/wp-content/uploads/2019/12/Zidane-1.jpg", "https://i.kym-cdn.com/entries/icons/original/000/038/806/tco_-_2021-11-10T112501.292.jpg",
25
+ "https://thumbs.dreamstime.com/z/homme-chinois-asiatique-d-affaires-7045702.jpg", "https://c8.alamy.com/compfr/b332ew/un-chinois-d-une-vingtaine-d-annees-avec-un-grand-sourire-b332ew.jpg",
26
+ "https://www.toutpourvosfetes.fr/30551-large_default/moustache-et-barbe-chinois.jpg", "https://thumbs.dreamstime.com/b/nain-petit-homme-4339718.jpg",
27
+ "https://pbs.twimg.com/media/GaecrTvaEAAreDl.jpg", "https://i.pinimg.com/736x/7f/a7/84/7fa78427092842091603dfcff6f849ca.jpg",
28
+ "https://retrogems.fr/wp-content/uploads/2025/12/asterion-copine-virale.jpg", "https://tribunedelyon.fr/wp-content/uploads/sites/5/2025/10/khalamite-pierre-ferrandis-10.jpg",
29
+ "https://media.tenor.com/JzOOJNV1gZUAAAAe/antoine-daniel-wtc.png", "https://www.pokepedia.fr/images/thumb/0/03/Lockpin-DP.png/800px-Lockpin-DP.png",
30
+ "https://i.pinimg.com/736x/8a/42/d2/8a42d20954675f8f5bcb931f2560d380.jpg", "https://www.clipartmax.com/png/middle/166-1665846_pikachu-meets-minecraft-by-drpoochew-pikachu-face-meme-png.png",
31
+ "https://www.picclickimg.com/ekoAAOSwrBBjrwRk/Flag-Palestine-Drapeau-Palestine-ecusson-brodu00e9-patche-thermocollant.webp",
32
  "https://www.radiofrance.fr/s3/cruiser-production/2019/10/2ccb44bb-6211-4340-b063-4d7a015575d4/1200x680_kaaris-or-noir.jpg_or_noir.jpg",
33
+ "https://i.ebayimg.com/images/g/jagAAOxyu1BTj-fx/s-l1200.jpg", "https://www.radiofrance.fr/s3/cruiser-production-eu3/2019/06/d12bbc34-45f9-4b03-b762-25ae9988b888/640x340_gettyimages-624736982.jpg",
34
+ "https://upload.wikimedia.org/wikipedia/fr/b/b2/Minecraft%2C_le_film.png",
 
35
  ]
36
 
37
  def get_server_status():
 
146
  @app.route('/wake', methods=['POST'])
147
  def wake():
148
  if not session.get('auth'): return redirect('/')
149
+
150
+ # On utilise un relais Web pour contourner le blocage UDP de l'hébergeur
151
+ relay_url = f"http://wakeonlan.me/?ip={MON_HOST_NOIP}&mac={MAC_ADRESSE.replace(':', '')}&pass=&schedule="
152
+
153
  try:
154
+ # On appelle le service de réveil
155
+ requests.get(relay_url, timeout=5)
156
+ msg = "Signal de réveil envoyé via relais !"
 
 
 
157
  except Exception as e:
158
+ msg = "Le relais n'a pas répondu, mais le PC se réveille peut-être."
159
 
160
  status_text, status_color = get_server_status()
161
  return render_template_string(HTML_TEMPLATE, logged_in=True, status_text=status_text,