Noch kein Bild — starte links die Kamera.
Im QR-Modus wird der Code automatisch erkannt und sauber neu erzeugt.
Noch kein Bild — starte links die Kamera.
Im QR-Modus wird der Code automatisch erkannt und sauber neu erzeugt.
Aus einer Datei (file://) lässt der Browser die Kamera nicht zu.
http://localhost gilt aber als sicherer Kontext — ein einfacher
lokaler Server genügt, kein HTTPS nötig. Speichere das Skript
als serve.ps1 im App-Ordner, führe es mit .\serve.ps1
aus und öffne http://localhost:8000/apps/camera/.
$port = 8000
$root = (Get-Location).Path
$listener = [System.Net.HttpListener]::new()
$listener.Prefixes.Add("http://localhost:$port/")
$listener.Start()
Write-Host "Laeuft auf http://localhost:$port/ (Strg+C beendet)"
$mime = @{ ".html"="text/html"; ".js"="text/javascript"; ".mjs"="text/javascript";
".css"="text/css"; ".json"="application/json"; ".png"="image/png"; ".jpg"="image/jpeg";
".svg"="image/svg+xml"; ".wasm"="application/wasm";
".xlsx"="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }
try {
while ($listener.IsListening) {
$ctx = $listener.GetContext()
$rel = [Uri]::UnescapeDataString($ctx.Request.Url.AbsolutePath.TrimStart('/'))
if ($rel -eq "") { $rel = "index.html" }
$path = Join-Path $root $rel
if (Test-Path $path -PathType Container) { $path = Join-Path $path "index.html" }
if (Test-Path $path -PathType Leaf) {
$ext = [System.IO.Path]::GetExtension($path).ToLower()
$ct = $mime[$ext]; if (-not $ct) { $ct = "application/octet-stream" }
$bytes = [System.IO.File]::ReadAllBytes($path)
$ctx.Response.ContentType = $ct
$ctx.Response.OutputStream.Write($bytes, 0, $bytes.Length)
} else { $ctx.Response.StatusCode = 404 }
$ctx.Response.Close()
}
} finally { $listener.Stop() }
Bei „Zugriff verweigert": PowerShell als Administrator starten — oder einmalig
freigeben mit netsh http add urlacl url=http://localhost:8000/ user=Jeder.
Hinweis: Foto-Aufnahme & Export (JPEG/PNG/WebP) laufen so komplett offline;
QR-Funktionen benötigen weiterhin Internet (Bibliotheken per CDN).