Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 11 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
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

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

To make your website available from other computers, set host to in the run method. The last line of the above Hello World should then read:

run(host='', port=8080)

You should now be able to access your website via the Pi's IP address, like this:

See the bottle documentation on deployment for further details.

share|improve this answer
On my Raspberry Pi, if I execute curl http://localhost:8080/hello/world I receive the expected results. However I want to be able to access this on my regular computer over the lan. After using ifconfig for my IP address, the following URL on my regular computer is unable to establish a connection: I am able to access another webpage I made at `';. Would you have any idea on how I can to my bottle page? – Matthew Moisen Sep 3 '13 at 3:21
Your home.php is implicitely accessed via port 80 (http) try running bottle on that port and if it succedes, make sure there are no Firewalls between or on your desktop and the pi blocking port 8080. – Bengt Sep 4 '13 at 15:09
It turns out that I needed to change my IP to either localhost or – Matthew Moisen Sep 4 '13 at 20:44

Install iPython Notebook.

rpi#> sudo apt-get install ipython-notebook ipython3-notebook

Then run it:

rpi#> ipython notebook

Note: You could access it also from a PC:
rpi#> ipython notebook --ip=
# here is my RPi IP.
# from another computer in browser I'm typing:

enter image description here

You'll see this:

enter image description here

Then create a new notebook and run Your code there:

enter image description here

Method test:

enter image description here



Youtube: https://www.youtube.com/watch?v=cJuF4IDMuLY

Very Important:

The music is running on RPi in background in linux screen program over mps-youtube.

rpi#> sudo apt-get install python3-pip
rpi#> sudo pip3 install --upgrade mps-youtube  
rpi#> sudo pip3 install --upgrade https://github.com/mps-youtube/pafy/archive/develop.zip
rpi#> mpsyt # to start it
    # configure mpsyt to show video, player.
    mpsyt#> set show_video True
    mpsyt#> set player omxplayer
    mpsyt#> set search_music False
    mpsyt#> . lindsey stirling
    mpsyt#> 2 # to play song from a list.

Good luck!

share|improve this answer
Your question could be improved... Why install Python notebook? What exactly does it do? It should certainly comment about potential security concerns (such as leave it open to the internet). – Jacobm001 Feb 23 at 20:26
@Jacobm001, not today, not now. If needed, follow Bibliography at bottom. – Vitalie Ghelbert Feb 25 at 6:40

Your Answer


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.