2

Is there a way to let a user write some python code on the browser and then run it and show the result? I want to make a coding challenges website using django but I don't know where to start

Comments
  • 1
    Yes and no.

    You just need a text area in the browser, it's the taking that input, sanitising the hell out of it, executing it against python and returning the results part that gets complicated and provides direct code execution to the server that's the problem.
  • 0
    @C0D4 that's exactly what I mean, I want to let the user do all the coding on the browser and once they submit it I can take that and try to run it, test it, whatever...
  • 2
    @juanchdzl look at something like https://repl.it

    Doing this on your own is asking for a compromised server in the wrong hands.
  • 0
    @C0D4 That one looks good but I basically want to clone https://www.codewars.com/

    but with just python challenges and a django backend
  • 1
    You can code a transpiler to export the Python code to js and run in on the browser
  • 0
    Yes.

    I dnt knw tho
  • 1
    @Afrographics that seems like a good idea, gonna do some research about it for sure
  • 0
    @Afrographics I came here to say exactly that: a python to JS transpiler.
Add Comment