title: Run Python scripts from JavaScript functions
body: <p>We need to run a Python code which will control the GPIO of Raspberry Pi 3 from within the JavaScript. (JavaScript is listening for changes on database and when changes are made, function gets triggered and it should run the Python Code.</p>
  
  <p><strong>(This code is not working, like the alert message will pop-up but the python code isn't running which otherwise should turn the LED on. What am i doing wrong?)</strong></p>
  
  <p><em>index.html file</em></p>
  
  <pre><code>function runPython()
  {
      $.ajax({
      type: "POST", 
      url: "/home/pi/Desktop/Web/led.py",
      data :{},
      success: callbackFunc
      });
  }
  
  function callbackFunc(response)
  {
      alert("working");
  }
  </code></pre>
  
  <p><em>led.py file</em></p>
  
  <pre><code>import RPi.GPIO as GPIO
  import timemGPIO.setmode(GPIO.BCM)
  GPIO.setwarnings(False)
  GPIO.setup(18, GPIO.OUT)
  print "LED on"
  GPIO.output(18, GPIO.HIGH)
  time.sleep(10)
  print "LED off"
  GPIO.output(18,GPIO.LOW)
  </code></pre>