On Mon, 4 Mar 2019 21:46:29 -0800 (PST),
sayalikutwal07@gmail.com declaimed the
following:
<SNIP>
And my backend gpio control python code is Here...
import Adafruit_BBIO.GPIO as GPIO
import time
outPin="P9_12"
GPIO.setup(outPin,GPIO.OUT)
while True:
GPIO.output(outPin, GPIO.HIGH)
Print “LED is ON”
time.sleep(10)
GPIO.output(outpin,GPIO.LOW)
Print “LED is OFF”
time.sleep(10)
How can i embedd this two code to control the led from web page without
using the PHP.
.
Well... the blunt response is: you don't. Your "backend" code is just a
loop toggling an LED every 10 seconds.
At the very least, you will need to be running a web-server capable of
invoking your application script passing it arguments for what has been
activated in the web page.
The least effective way would be original CGI (study the Python
Standard Library documentation for the cgi module). Can't help on
configuring the web-server to invoke your script...
Next step (if this is not meant to be a production application) would
be to read the documentation for Python's BaseHTTPServer and in particular
CGIHTTPServer (Python 2.x; http.server module for Python 3.x) and create
your own server running on some unprivileged port, which can invoke your
CGI scripts.
Above that, Google for documentation on how to use Flask, Django, or
other Python-based web application framework (these usually include a
"development server" mode, so one can test without configuring Apache or
similar). These typically build everything into one "application" rather
than invoking standalone programs for each request.