Control beaglebone GPIO pins from web page without using the PHP..

Hello…
I want to control gpio pins of beaglebone from web page.for that i have written back-end python code to ON and OFF the led. and front-end html code to create web page.
How can i embedd this two code and control the led from web page without using the PHP.

My front end HTML code is here…

`

On

Off

`

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.
.

This really has nothing to do with the BB. You should look into python flask or a similar framework since you’re using python. There are many options. You need something to replace what php be doing for you.

Regards

Jim

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.

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…

html.txt (194 Bytes)

ledon.py (187 Bytes)

On Wed, 6 Mar 2019 17:19:15 +0530, sayali kutwal
<sayalikutwal07@gmail.com> declaimed the
following:

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..

  As you've been told -- at the bottom level, you need to configure some
type of web server to treat invoke your script(s) via CGI (common gateway
interface -- very old and not really used directly these days since it
requires spawning a process for each request and then cleaning up; more
modern frameworks keep one process running which handles the entire
"application"). I can't help with configuring Apache (which I believe is
already running if Cloud9 runs). You also need to configure your script(s)
to obtain the CGI environment data (using the CGI module).

  Or you write an application using a web framework and test it using a
development server (which most frameworks provide).

https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
(Bad news -- most framework tutorials focus on text based forms (blogs,
message forums) with single submit buttons, and not on multiple button
actions; so creating an application using a linked pair of radio buttons

  () On
  (*) Off
  [Submit]

to select a state, and then a [submit] to activate that state, is simple.
creating

  [On] [Off]

not so much...)

http://flask.pocoo.org/docs/1.0/quickstart/