#!/usr/bin/env python3 """ Simple CGI script to refresh the gallery. Just calls the main generate_gallery.py script. """ import subprocess def main(): # Output HTTP headers print("Content-Type: text/plain") print("Cache-Control: no-cache") print() # Empty line to end headers try: # Call the gallery generation script result = subprocess.run( [ "python3", "/work/kschmidt/web/generate_gallery.py" ], capture_output=True, text=True, timeout=300, ) if result.returncode == 0: print("Gallery refresh successful!") print("\nOutput:") print(result.stdout) if result.stderr: print("\nWarnings:") print(result.stderr) else: print(f"Gallery refresh failed with return code " f"{result.returncode}") print("\nError output:") print(result.stderr) if result.stdout: print("\nStandard output:") print(result.stdout) except subprocess.TimeoutExpired: print("Gallery refresh timed out after 5 minutes") except Exception as e: print(f"Error running gallery refresh: {e}") import traceback traceback.print_exc() if __name__ == "__main__": main()