0

I have built a platform on django for running python scripts. The user is able to write their Python script in a text-area and when a button is clicked, the script should run on the back-end. It should also check for test cases from a database (like Hackerrank).

I have tried using the eval() function but the problem is that when the user writes input() in their code it should take the values from database for input.

Please help me figure this out.

itsols
  • 5,406
  • 7
  • 51
  • 95
Jatin Gupta
  • 71
  • 1
  • 3
  • Please don't use `eval`, it is really ev*i*l: https://stackoverflow.com/questions/1832940/why-is-using-eval-a-bad-practice It is a very unsafe way to handle a call. A hacker might read out the entire database, or stop your server. – Willem Van Onsem May 21 '19 at 10:39
  • you'll need to be more specific and show us the code. what values from database? if user inputs a string, how do you know what should be replaced? give a concrete example, show what's in the database, walk us through your problem. – dirkgroten May 21 '19 at 10:39
  • @jatin can you please show us your code. – NVS May 21 '19 at 10:40
  • Edited the question + title to fix language and spelling issues. – itsols May 21 '19 at 16:10

0 Answers0