Skip to content

Commit

Permalink
Remove unnecessary file removal code and update print log
Browse files Browse the repository at this point in the history
  • Loading branch information
sschonss committed Jan 10, 2024
1 parent e11a75e commit 80de65f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
8 changes: 0 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,10 @@ func printImage(w http.ResponseWriter, r *http.Request) {
return
}

err = os.Remove(imagePath)
if err != nil {
log.Printf("Error removing file: %s\n", err)
http.Error(w, "Failed to remove the file", http.StatusInternalServerError)
return
}

fmt.Fprintf(w, "Print request processed successfully.\n%s\n", output)
}



func explainAPI(w http.ResponseWriter, r *http.Request) {
enableCors(&w)
explanation := `
Expand Down
2 changes: 2 additions & 0 deletions scripts/autoprinter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ for ($i = 0; $i -lt $num_copies; $i++) {
Start-Process -FilePath "mspaint.exe" -ArgumentList "/pt `"$image_file`" `"$printer_name`""
}

Remove-Item $image_file

Write-Host "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss'): Printing of $num_copies copies of file '$image_file' on printer '$printer_name' completed"
"Image '$image_file' sent for printing ($num_copies copies) to $printer_name" | Out-File -Append -FilePath print_log.txt
"Logs saved in print_log.txt" | Out-File -Append -FilePath print_log.txt
1 change: 1 addition & 0 deletions scripts/autoprinter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ convert "$image_file" -rotate 90 -resize 'x792' "$temp_image"
} >> print_log.txt

rm "$temp_image"
rm "$image_file"

echo "Resized image '$temp_image' sent for printing ($num_copies copies) to $printer_name"
echo "Logs saved in print_log.txt"

0 comments on commit 80de65f

Please sign in to comment.