From db3964eae80d70ed58af6211c2cd771f53e7960b Mon Sep 17 00:00:00 2001
From: Quinta <0pietroquintavalle0@gmail.com>
Date: Thu, 20 Jun 2024 00:16:43 +0200
Subject: [PATCH] Fixing
---
components/navigation.tsx | 3 ---
pages/api/run-code.ts | 48 ---------------------------------------
2 files changed, 51 deletions(-)
delete mode 100644 pages/api/run-code.ts
diff --git a/components/navigation.tsx b/components/navigation.tsx
index 79bbc62..9223158 100644
--- a/components/navigation.tsx
+++ b/components/navigation.tsx
@@ -18,9 +18,6 @@ export default function Navigation() {
))}
-
-
-
)
diff --git a/pages/api/run-code.ts b/pages/api/run-code.ts
deleted file mode 100644
index 2be0306..0000000
--- a/pages/api/run-code.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import type { NextApiRequest, NextApiResponse } from "next";
-import { exec } from "child_process";
-import fs from "fs";
-import path from "path";
-
-export default async function handler(req: NextApiRequest, res: NextApiResponse) {
- if (req.method === "POST") {
- try {
- const { code } = req.body;
-
- console.log("Received code:", code);
-
- const tempFilePath = path.join(process.cwd(), "temp.java");
- console.log("Temporary file path:", tempFilePath);
-
- fs.writeFileSync(tempFilePath, code);
-
- const compileCommand = `javac ${tempFilePath}`;
- const runCommand = `java -cp ${path.dirname(tempFilePath)} Temp`;
-
- console.log("Compile command:", compileCommand);
- console.log("Run command:", runCommand);
-
- exec(compileCommand, (compileError, compileStdout, compileStderr) => {
- if (compileError) {
- console.error("Compilation error:", compileStderr);
- res.status(500).json({ error: compileStderr });
- return;
- }
-
- exec(runCommand, (runError, runStdout, runStderr) => {
- if (runError) {
- console.error("Execution error:", runStderr);
- res.status(500).json({ error: runStderr });
- } else {
- console.log("Execution output:", runStdout);
- res.status(200).json({ output: runStdout });
- }
- });
- });
- } catch (error) {
- console.error("Handler error:", error);
- res.status(500).json({ error: error.message });
- }
- } else {
- res.status(405).json({ error: "Method not allowed" });
- }
-}