diff --git a/webapp/src/components/Terminal/TerminalComp.jsx b/webapp/src/components/Terminal/TerminalComp.jsx index 7fa2b1f..6b1c745 100644 --- a/webapp/src/components/Terminal/TerminalComp.jsx +++ b/webapp/src/components/Terminal/TerminalComp.jsx @@ -1,22 +1,43 @@ -import React from "react"; +import React, { useState } from "react"; import { ReactTerminal } from "react-terminal"; - +import axios from "axios"; import "./Terminal.css"; const TerminalComp = () => { + const [output, setOutput] = useState(""); + + const handleCommand = async (command) => { + try { + const { data } = await axios.post("http://127.0.0.1:10000/gdb_command", { + command: command, + name: "program", + }); + return data["result"]; + } catch (error) { + return "Error executing command"; + } + }; + return (
- TerminalComp { + return await handleCommand(command); + }, + }} + defaultHandler={async (command) => { + return await handleCommand(command); + }} />
); diff --git a/webapp/src/main.jsx b/webapp/src/main.jsx index 446bd5f..76403de 100644 --- a/webapp/src/main.jsx +++ b/webapp/src/main.jsx @@ -3,15 +3,18 @@ import React from "react"; import ReactDOM from "react-dom"; import { BrowserRouter } from "react-router-dom"; import { DataProvider } from "./context/DataContext"; +import { TerminalContextProvider } from "react-terminal"; import App from "./App"; import "./index.css"; ReactDOM.render( - - - + + + + + , document.getElementById("root")