This article illustrates how to control remotely via web a GPIO line using the Tornado web server for Python

To follow this article you have to install Tornado on your CORE9G25 Board.

The first attempt is to control a led wired on an CORE9G25 board.

The files used are:

Led controller

Led control panelONOFF

Last status message: web server): Position: CD://Debian/python/tornado/led/

import tornado.ioloop
import tornado.web
import ablib

class ledon(tornado.web.RequestHandler):
	def get(self):
		print "Led ON"
		self.write("Led ON")

class ledoff(tornado.web.RequestHandler):
	def get(self): 
		print "Led OFF"
		self.write("Led OFF")

application = tornado.web.Application([
	(r"/ledon", ledon),
	(r"/ledoff", ledoff),
	(r"/(.*)", tornado.web.StaticFileHandler, {"path": ".","default_filename": "index.html"}),

if __name__ == "__main__":
	led = ablib.Daisy11('D11','L1')


index.html: A simple html page with two buttons. Position: CD://Debian/python/tornado/led/index.html

Go the CD://Debian/python/tornado/led/index.html to see the file details

The web site icon: favico.ico

type the follow command:

debarm:~/playground/python/tornado/led# python

It is possible to use a different GPIO line just changing the line

led = ablib.Daisy11('D11','L1')

Open your browser and try to send the on-off command directly using these urls:

Now open the default web page:

and turn on-off the led using the two HTML buttons like these:

Led control panel  


Last status message:

Related links

Documentation Terms of Use
The Acme Systems srl provides this Debian system development and user manual.
The origin of these doc came from the website:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Creative Commons License

关注我们: 微博

销售电话: +86-755-29638421

Copyright @ 2014 to 2020 - 核风智能技术有限公司