Skip to content

Instantly share code, notes, and snippets.

@s-geissler
Created January 9, 2026 22:40
Show Gist options
  • Select an option

  • Save s-geissler/8f91e9789d736ae986e039ef0df45a3f to your computer and use it in GitHub Desktop.

Select an option

Save s-geissler/8f91e9789d736ae986e039ef0df45a3f to your computer and use it in GitHub Desktop.
A simple HTML file that embeds the snapmaker U1 camera into a semi-live feed
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Printer Monitor</title>
<style>
body { margin: 0; background: #111; display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; overflow: hidden; font-family: sans-serif; }
img { max-width: 100%; max-height: 100%; border: 2px solid #333; }
#info { position: absolute; top: 10px; right: 10px; color: #00ff00; font-size: 12px; text-align: right; opacity: 0.7; }
</style>
</head>
<body>
<div id="info">
<div id="status">Connecting...</div>
<div id="interval-display"></div>
</div>
<img id="webcam" src="http://<YOUR PRINTER IP>/server/files/camera/monitor.jpg">
<script>
const imgElement = document.getElementById('webcam');
const status = document.getElementById('status');
const intervalDisplay = document.getElementById('interval-display');
const baseUrl = "http://<YOUR PRINTER IP>/server/files/camera/monitor.jpg";
const urlParams = new URLSearchParams(window.location.search);
const refreshInterval = parseInt(urlParams.get('interval')) || 5000;
intervalDisplay.textContent = `Interval: ${refreshInterval}ms`;
function updateImage() {
const nextImg = new Image();
const timestamp = new Date().getTime();
const newSrc = `${baseUrl}?t=${timestamp}`;
nextImg.onload = () => {
imgElement.src = newSrc;
status.textContent = "Live - " + new Date().toLocaleTimeString();
status.style.color = "#00ff00";
};
nextImg.onerror = () => {
status.textContent = "Offline / Retrying...";
status.style.color = "red";
};
nextImg.src = newSrc;
}
setInterval(updateImage, refreshInterval);
updateImage();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment