Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -147,19 +147,21 @@ def login():
|
|
| 147 |
def wake():
|
| 148 |
if not session.get('auth'): return redirect('/')
|
| 149 |
|
| 150 |
-
|
| 151 |
try:
|
| 152 |
-
#
|
| 153 |
-
# Parfois, changer de service de relais suffit à débloquer la Bbox
|
| 154 |
target_ip = socket.gethostbyname(MON_HOST_NOIP)
|
| 155 |
|
| 156 |
-
#
|
| 157 |
-
url = f"https://www.dnsexit.com/api/wol?mac={
|
| 158 |
|
| 159 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
| 160 |
r = requests.get(url, headers=headers, timeout=10)
|
| 161 |
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
except Exception as e:
|
| 165 |
msg = f"Erreur : {str(e)}"
|
|
@@ -168,14 +170,6 @@ def wake():
|
|
| 168 |
return render_template_string(HTML_TEMPLATE, logged_in=True, status_text=status_text,
|
| 169 |
status_color=status_color, bg_image=IMAGE_FOND,
|
| 170 |
galerie=IMAGES_GALERIE, show_snake=True, message=msg)
|
| 171 |
-
|
| 172 |
-
except Exception as e:
|
| 173 |
-
msg = f"Erreur de relais : {str(e)}"
|
| 174 |
-
|
| 175 |
-
status_text, status_color = get_server_status()
|
| 176 |
-
return render_template_string(HTML_TEMPLATE, logged_in=True, status_text=status_text,
|
| 177 |
-
status_color=status_color, bg_image=IMAGE_FOND,
|
| 178 |
-
galerie=IMAGES_GALERIE, show_snake=True, message=msg)
|
| 179 |
|
| 180 |
if __name__ == "__main__":
|
| 181 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 147 |
def wake():
|
| 148 |
if not session.get('auth'): return redirect('/')
|
| 149 |
|
| 150 |
+
mac_clean = MAC_ADRESSE.replace(':', '').upper()
|
| 151 |
try:
|
| 152 |
+
# Résolution DNS de ton IP publique
|
|
|
|
| 153 |
target_ip = socket.gethostbyname(MON_HOST_NOIP)
|
| 154 |
|
| 155 |
+
# On utilise le service DNSExit qui est très direct
|
| 156 |
+
url = f"https://www.dnsexit.com/api/wol?mac={mac_clean}&host={target_ip}"
|
| 157 |
|
| 158 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
| 159 |
r = requests.get(url, headers=headers, timeout=10)
|
| 160 |
|
| 161 |
+
if r.status_code == 200:
|
| 162 |
+
msg = f"🚀 Signal envoyé à {target_ip} !"
|
| 163 |
+
else:
|
| 164 |
+
msg = f"Signal envoyé (Code {r.status_code})"
|
| 165 |
|
| 166 |
except Exception as e:
|
| 167 |
msg = f"Erreur : {str(e)}"
|
|
|
|
| 170 |
return render_template_string(HTML_TEMPLATE, logged_in=True, status_text=status_text,
|
| 171 |
status_color=status_color, bg_image=IMAGE_FOND,
|
| 172 |
galerie=IMAGES_GALERIE, show_snake=True, message=msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
if __name__ == "__main__":
|
| 175 |
app.run(host='0.0.0.0', port=7860)
|