Reputation:
I've gotten a task at University to create a website for teaching other students how to use python libraries (Scrapy, BS) for web scraping. I've already set up the frontend part with React and React Ace editor and now I'm trying to figure out how pass code that user entered to the script. Do I need to make my own server (api) or I can call the python script directly and pass all the code using ajax request?
What is the best approach?
What I want is to pass all the code that user entered in the online editor to the python script and then return the output of that script as a response to the initial request, so that I could check whether the result is correct.
Upvotes: 0
Views: 234
Reputation: 482
my suggestion is to create a server with API (it's actually AJAX) and then to run the Python code, one good option us to create express app (Node.js HTTP server) and use python-shell see the first example with runString option.
you will need a server with node.js and python installed.
of course this only for a university task, in this option you run the code on your server, and it's a pretty big security issue.
Upvotes: 1