Spaces:
Paused
Paused
Download app/api/kill-sandbox/route.ts from Leon4gr45/paper2code-cli: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/Leon4gr45/paper2code-cli/resolve/main/app/api/kill-sandbox/route.ts
- Command line
-
hf download hf://spaces/Leon4gr45/paper2code-cli/app/api/kill-sandbox/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/Leon4gr45/paper2code-cli/resolve/main/app/api/kill-sandbox/route.ts
1.19 kB
| import { NextResponse } from 'next/server'; | |
| declare global { | |
| var activeSandboxProvider: any; | |
| var sandboxData: any; | |
| var existingFiles: Set<string>; | |
| } | |
| export async function POST() { | |
| try { | |
| console.log('[kill-sandbox] Stopping active sandbox...'); | |
| let sandboxKilled = false; | |
| // Stop existing sandbox if any | |
| if (global.activeSandboxProvider) { | |
| try { | |
| await global.activeSandboxProvider.terminate(); | |
| sandboxKilled = true; | |
| console.log('[kill-sandbox] Sandbox stopped successfully'); | |
| } catch (e) { | |
| console.error('[kill-sandbox] Failed to stop sandbox:', e); | |
| } | |
| global.activeSandboxProvider = null; | |
| global.sandboxData = null; | |
| } | |
| // Clear existing files tracking | |
| if (global.existingFiles) { | |
| global.existingFiles.clear(); | |
| } | |
| return NextResponse.json({ | |
| success: true, | |
| sandboxKilled, | |
| message: 'Sandbox cleaned up successfully' | |
| }); | |
| } catch (error) { | |
| console.error('[kill-sandbox] Error:', error); | |
| return NextResponse.json( | |
| { | |
| success: false, | |
| error: (error as Error).message | |
| }, | |
| { status: 500 } | |
| ); | |
| } | |
| } |