Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,6 @@ MOT_DE_PASSE = "pouletcrousty"
|
|
| 13 |
MC_PORT = 25565
|
| 14 |
IMAGE_FOND = "https://images.alphacoders.com/132/1327533.png"
|
| 15 |
|
| 16 |
-
# ... (IMAGES_GALERIE et get_server_status restent identiques)
|
| 17 |
IMAGES_GALERIE = [
|
| 18 |
"https://i.redd.it/ag4307hy62qe1.jpeg", "https://pbs.twimg.com/profile_images/1627794683362480129/3xUrVnUY_400x400.jpg",
|
| 19 |
"https://sativa.fr/wp-content/uploads/SnoopDogg.jpg", "https://media.zenfs.com/fr_FR/News/Gameblog/kate-upton-gta-v.jpg",
|
|
@@ -51,7 +50,6 @@ def get_server_status():
|
|
| 51 |
except:
|
| 52 |
return "HORS LIGNE 🔴", "#ff4444"
|
| 53 |
|
| 54 |
-
# ... (HTML_TEMPLATE reste identique)
|
| 55 |
HTML_TEMPLATE = '''
|
| 56 |
<!DOCTYPE html>
|
| 57 |
<html>
|
|
@@ -83,86 +81,4 @@ HTML_TEMPLATE = '''
|
|
| 83 |
{% if not logged_in %}
|
| 84 |
<form method="post" action="/login">
|
| 85 |
<input type="password" name="password" placeholder="Mot de passe" style="padding:12px; border-radius:8px; width: 80%; border:none;"><br><br>
|
| 86 |
-
<button type="submit" class="btn-wake" style="background: #2563eb;">CONNEXION
|
| 87 |
-
</form>
|
| 88 |
-
{% else %}
|
| 89 |
-
{% if message %} <div class="confirmation">⚡ {{ message }}</div> {% endif %}
|
| 90 |
-
{% if show_snake %}
|
| 91 |
-
<canvas id="snakeGame" width="300" height="300"></canvas>
|
| 92 |
-
<div class="keys">
|
| 93 |
-
<div class="key">↑</div><div class="key">↓</div><div class="key">←</div><div class="key">→</div>
|
| 94 |
-
</div>
|
| 95 |
-
<script>
|
| 96 |
-
const canvas = document.getElementById("snakeGame"); const ctx = canvas.getContext("2d");
|
| 97 |
-
let snake = [{x:10, y:10}]; let food = {x:5, y:5}; let dx=0, dy=0;
|
| 98 |
-
document.addEventListener("keydown", e => {
|
| 99 |
-
if(e.key==="ArrowUp" && dy===0) {dx=0; dy=-1;}
|
| 100 |
-
if(e.key==="ArrowDown" && dy===0) {dx=0; dy=1;}
|
| 101 |
-
if(e.key==="ArrowLeft" && dx===0) {dx=-1; dy=0;}
|
| 102 |
-
if(e.key==="ArrowRight" && dx===0) {dx=1; dy=0;}
|
| 103 |
-
});
|
| 104 |
-
function draw() {
|
| 105 |
-
let head = {x: snake[0].x + dx, y: snake[0].y + dy};
|
| 106 |
-
snake.unshift(head);
|
| 107 |
-
if(head.x===food.x && head.y===food.y) {
|
| 108 |
-
food = {x:Math.floor(Math.random()*15), y:Math.floor(Math.random()*15)};
|
| 109 |
-
} else { snake.pop(); }
|
| 110 |
-
if(head.x<0 || head.x>=15 || head.y<0 || head.y>=15) return location.reload();
|
| 111 |
-
ctx.fillStyle = "black"; ctx.fillRect(0,0,300,300);
|
| 112 |
-
ctx.fillStyle = "red"; ctx.fillRect(food.x*20, food.y*20, 18, 18);
|
| 113 |
-
ctx.fillStyle = "#2563eb"; snake.forEach(p => ctx.fillRect(p.x*20, p.y*20, 18, 18));
|
| 114 |
-
setTimeout(draw, 100);
|
| 115 |
-
} draw();
|
| 116 |
-
</script>
|
| 117 |
-
{% else %}
|
| 118 |
-
<form action="/wake" method="post">
|
| 119 |
-
<button type="submit" class="btn-wake">🚀 ALLUMER SERVEUR</button>
|
| 120 |
-
</form>
|
| 121 |
-
{% endif %}
|
| 122 |
-
<p><a href="/" style="color: #666; text-decoration: none; font-size: 0.8em; margin-top: 20px; display: block;">🔄 ACTUALISER</a></p>
|
| 123 |
-
{% endif %}
|
| 124 |
-
</div>
|
| 125 |
-
<script>
|
| 126 |
-
document.querySelectorAll('.sticker').forEach((s, i) => {
|
| 127 |
-
s.style.left = Math.floor(Math.random() * 80) + "%";
|
| 128 |
-
s.style.top = Math.floor(Math.random() * 80) + "%";
|
| 129 |
-
s.style.transform = "rotate(" + (Math.floor(Math.random() * 40) - 20) + "deg)";
|
| 130 |
-
});
|
| 131 |
-
</script>
|
| 132 |
-
</body>
|
| 133 |
-
</html>
|
| 134 |
-
'''
|
| 135 |
-
|
| 136 |
-
@app.route('/')
|
| 137 |
-
def index():
|
| 138 |
-
status_text, status_color = get_server_status()
|
| 139 |
-
return render_template_string(HTML_TEMPLATE, logged_in=session.get('auth'),
|
| 140 |
-
status_text=status_text, status_color=status_color,
|
| 141 |
-
bg_image=IMAGE_FOND, galerie=IMAGES_GALERIE, show_snake=False)
|
| 142 |
-
|
| 143 |
-
@app.route('/login', methods=['POST'])
|
| 144 |
-
def login():
|
| 145 |
-
if request.form.get('password') == MOT_DE_PASSE: session['auth'] = True
|
| 146 |
-
return redirect('/')
|
| 147 |
-
|
| 148 |
-
@app.route('/wake', methods=['POST'])
|
| 149 |
-
def wake():
|
| 150 |
-
if not session.get('auth'): return redirect('/')
|
| 151 |
-
|
| 152 |
-
mac = MAC_ADRESSE.replace(':', '')
|
| 153 |
-
try:
|
| 154 |
-
target_ip = socket.gethostbyname(MON_HOST_NOIP)
|
| 155 |
-
# Utilisation de Depicus, service de WOL très robuste
|
| 156 |
-
depicus_url = f"https://www.depicus.com/wake-on-lan/woli?m={mac}&i={target_ip}&s=255.255.255.255&p=9"
|
| 157 |
-
requests.get(depicus_url, headers={'User-Agent': 'Mozilla/5.0'}, timeout=10)
|
| 158 |
-
msg = "🚀 Signal envoyé ! Le PC devrait s'allumer."
|
| 159 |
-
except Exception as e:
|
| 160 |
-
msg = f"Erreur : {str(e)}"
|
| 161 |
-
|
| 162 |
-
status_text, status_color = get_server_status()
|
| 163 |
-
return render_template_string(HTML_TEMPLATE, logged_in=True, status_text=status_text,
|
| 164 |
-
status_color=status_color, bg_image=IMAGE_FOND,
|
| 165 |
-
galerie=IMAGES_GALERIE, show_snake=True, message=msg)
|
| 166 |
-
|
| 167 |
-
if __name__ == "__main__":
|
| 168 |
-
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 13 |
MC_PORT = 25565
|
| 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",
|
|
|
|
| 50 |
except:
|
| 51 |
return "HORS LIGNE 🔴", "#ff4444"
|
| 52 |
|
|
|
|
| 53 |
HTML_TEMPLATE = '''
|
| 54 |
<!DOCTYPE html>
|
| 55 |
<html>
|
|
|
|
| 81 |
{% if not logged_in %}
|
| 82 |
<form method="post" action="/login">
|
| 83 |
<input type="password" name="password" placeholder="Mot de passe" style="padding:12px; border-radius:8px; width: 80%; border:none;"><br><br>
|
| 84 |
+
<button type="submit" class="btn-wake" style="background: #2563eb;">CONNEXION
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|