Hello
 For control GPIO pin from web page. I have written python the for make
beaglebone GPIO pin high ie LED ON.I create the two button ON and OFF using
HTML.Now i want to do, when i click on ON button from web page the the
python script  run and GPIO  pin of beaglebone make high ie LED ON.but i
dont know how can i attach my python script to html code.How can i add the
my python code path in html code to run python code by click on ON button.
 My python and html code attached here..

On Tue, Mar 5, 2019 at 9:31 PM Dennis Lee Bieber <[email protected]>
wrote:

> On Mon, 4 Mar 2019 21:46:29 -0800 (PST),
> [email protected] 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.
>
>
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         [email protected]    HTTP://wlfraed.home.netcom.com/
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "BeagleBoard" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/beagleboard/npb4CY_SM04/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/6j6t7e5rpcvqd7kpud7rri5ie02b38efvv%404ax.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CAC6i%3DDK%3DAHTA9nKPk9JoyfvdMBntUOXxbZF%3DKhN7-Ze0mKQi7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
<html>
<body>
    <form method="post">
    <p>
       <button name="button">On</button>
    </p>
    <p>
        <button name="btn">Off</button>
    </p>
    </form>
</body>
</html>
import Adafruit_BBIO.GPIO as GPIO
from time import sleep

outPin="P9_12"
GPIO.setup(outPin,GPIO.OUT)
while True:
   GPIO.output(outPin, GPIO.HIGH)
   print('LED ON')
   sleep(3)

Reply via email to