Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

365
Views
shell_exec ()in php does not execute in for loop in script python

Hello gears I'm trying to run a python script from a site, following your recommendation I use ajax but it brings me back the python code and does not execute the code.

Here is the code on the browser side

<script>

 document.getElementById("button").onclick = function () {
    $.ajax({
        type: 'POST',
        url: "projet.py",
        data: {param: ""}, //passing some input here
        success: function(response){
           console.log(output);
        }
     })
  };

</script>

  <div class="button" id="button">
    Start
</div>
  #!/usr/bin/python3
import pymysql.cursors
import time
import serial

# Connect to the database
connection = pymysql.connect(host='localhost',
                             user='root',
                             password='******',
                             database='iot',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)
time.sleep(0.5)

while 1 :
    ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
    ser.flush()
    while True:
        if ser.in_waiting > 0:
            line = ser.readline().decode('utf-8').rstrip()
            print("Valeur recu :{}".format(line))
            break
    time.sleep(0.5)
    with connection:
        with connection.cursor() as cursor:
            # Create a new record
            sql = "INSERT INTO `tension` (`valeur`) VALUES (%s)"
            cursor.execute(sql, (line))

        # connection is not autocommit by default. So you must commit to save
        # your changes.
        connection.commit()
        time.sleep(0.5)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!