Tell me more ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I have seen a lot of projects which claim to control the GPIO pins, but I want something a bit different, for example, to be able to blink an LED.

Is there a system out there where, via a web interface, I can click and execute a python script, for example "blink.py" on my raspberry.

Thank you

share|improve this question

2 Answers

up vote 3 down vote accepted

You could make this happen in any number of ways using CGI or other server side script. One problem will be permissions to accessing GPIO pins. There doesn't seem to be a clean solution. Currently it might be easiest to chown the gpio files to the user that runs the web server, call a (suid) program that can access the pins or have a separate daemon with access to the pins that you can send messages to (signal, pipe/socket, other ipc...).

For "executing a python script via a web interface", you might want to look at web.py. It's a very neat little module that lets you write a single file standalone "web service" that could do anything. Very handy for this kind of thing IME. Requires effectively no configuration or special software (apart from common python install and web.py itself). Just write handlers for urls in python, optionally with html templates and run. Point a client (browser, other script, wget..) at the right port and it just works. :)

Edit: A new project spotted, serpint seems to allow wiggling gpio from a socket or possibly fake char device interface.

share|improve this answer
2  
flask seems similar to web.py. There is also Django which seems to have more features - probably overkill for this project. – Frepa Nov 6 '12 at 17:17

If you are just starting with webdevelopment, have a look at Bottle. Bottle is simpler than flask in the sense that it is a complete web-framework within a single file. In contrast, Flask aims to reuse sound code from different libraries and might therefore be more solid, but also more complex.

Here is the Hello World with Bottle:

from bottle import route, run, template

@route('/hello/:name')
def index(name='World'):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='localhost', port=8080)

Run it with:

python HelloBottle.py

And open in a browser http://localhost:8080/hello/world.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.