···
.gallery {{ display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }}
.photo {{ border: 1px solid #ddd; padding: 5px; }}
.photo img {{ width: 100%; height: auto; }}
63
-
.photo a {{ display: block; text-align: center; margin-top: 5px; }}
63
+
.photo .actions {{ text-align: center; margin-top: 5px; }}
64
+
.photo .actions a {{ margin: 0 5px; }}
const ws = new WebSocket('ws://' + window.location.hostname + ':8765');
···
window.location.reload();
74
+
function deletePhoto(filename) {{
75
+
if(confirm('Are you sure you want to delete this photo?')) {{
76
+
fetch('/delete/' + filename, {{
78
+
}}).then(response => {{
80
+
window.location.reload();
···
<img src="/{filename}" alt="{timestamp}">
106
-
<a href="/{filename}" download>Download</a>
119
+
<div class="actions">
120
+
<a href="/{filename}" download>Download</a>
121
+
<a href="#" onclick="deletePhoto('{filename}'); return false;">Delete</a>
···
self.wfile.write(html.encode())
138
+
if self.path.startswith('/delete/'):
139
+
filename = self.path[8:] # Remove '/delete/' prefix
140
+
file_path = os.path.join(Config.PHOTO_DIR, filename)
143
+
if os.path.exists(file_path) and os.path.isfile(file_path):
144
+
os.remove(file_path)
145
+
logger.info(f"Deleted photo: {filename}")
146
+
self.send_response(200)
147
+
self.send_header('Content-type', 'text/plain')
149
+
self.wfile.write(b"File deleted successfully")
150
+
asyncio.run(notify_clients())
152
+
self.send_response(404)
153
+
self.send_header('Content-type', 'text/plain')
155
+
self.wfile.write(b"File not found")
156
+
except Exception as e:
157
+
logger.error(f"Error deleting file {filename}: {str(e)}")
158
+
self.send_response(500)
159
+
self.send_header('Content-type', 'text/plain')
161
+
self.wfile.write(b"Error deleting file")
163
+
self.send_response(404)
async def websocket_handler(websocket, path):
connected_clients.add(websocket)