Search code examples
javascriptherokugccservercodemirror

How can I compile code recieved through a textarea element from a webpage?


I am trying to execute the code written in a text area (using codemirror js)

    <textarea id="editor" cols="100" rows="50"></textarea>

I want to execute this code on my Heroku server but I cannot compile it as it does not have GCC installed on it. Can I install GCC on my (Free tier) Heroku server? Is there a different way to do it? Any possible solution is welcome.


Solution

  • Well, you would need to decide on a backend to use.

    You can get the textfields content in a number of ways, like sending it through the use of a html form to any recipient, like a php script or send it via Javascript calls, or any other way.

    Then you'd probably want to sanitize the users input to make sure it's not malicious

    then you need to write the piece of software that feeds the code to an interpreter, and wait for it's result

    And then you will need a piece of software that will send those results back to the user.