···
.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; }}
+
.photo .actions {{ text-align: center; margin-top: 5px; }}
+
.photo .actions a {{ margin: 0 5px; }}
const ws = new WebSocket('ws://' + window.location.hostname + ':8765');
···
window.location.reload();
+
function deletePhoto(filename) {{
+
if(confirm('Are you sure you want to delete this photo?')) {{
+
fetch('/delete/' + filename, {{
+
}}).then(response => {{
+
window.location.reload();
···
<img src="/{filename}" alt="{timestamp}">
+
<a href="/{filename}" download>Download</a>
+
<a href="#" onclick="deletePhoto('{filename}'); return false;">Delete</a>
···
self.wfile.write(html.encode())
+
if self.path.startswith('/delete/'):
+
filename = self.path[8:] # Remove '/delete/' prefix
+
file_path = os.path.join(Config.PHOTO_DIR, filename)
+
if os.path.exists(file_path) and os.path.isfile(file_path):
+
logger.info(f"Deleted photo: {filename}")
+
self.send_response(200)
+
self.send_header('Content-type', 'text/plain')
+
self.wfile.write(b"File deleted successfully")
+
asyncio.run(notify_clients())
+
self.send_response(404)
+
self.send_header('Content-type', 'text/plain')
+
self.wfile.write(b"File not found")
+
logger.error(f"Error deleting file {filename}: {str(e)}")
+
self.send_response(500)
+
self.send_header('Content-type', 'text/plain')
+
self.wfile.write(b"Error deleting file")
+
self.send_response(404)
async def websocket_handler(websocket, path):
connected_clients.add(websocket)