Photographing water drops using Raspberry Pi

The first result with the new control panel …

2014_REH2444

Advertisements

Photographing water drops using Raspberry Pi – The web server

The python – flask – web server.

I told you that I will publish the program code to communicate with the Raspberry Pi via web interface. This is part one. I show you the requirements.

I decided me to use python and flask, because I know how can I control the Raspberry GPIO pins with python. And the web server is a python web server! We need no java or javascript, no php or other languages for our project.

We need python (already installed) and an additional package, named flask. Flask is a powerful framework for python. No worry, it’s easy to use.

To install flask, we need the python pip module. So, you must install two packages (as root, or using sudo):

    
      apt-get install python-pip
      pip install flask

The next step is creating the folder structure. For our project, we need a main folder. I name this folder waterdrops.
In this folder we need the following subfolder: static and templates.

    /
    |-- waterdrops
           |-- static
           |-- templates

In the subfolder static we store images, which we use at the web page. The html pages are stored into the template subfolder.
The main program is stored in the main folder (waterdrops).

The files we use:
– index.html   (the main web page)
– layout.html  (the master web page )
– favicon.ico   (a small icon  like google, not necessary)
– wassertropfen.JPG (a picture for our web page)
– drops.py (the main python program)

    |-- waterdrops
           |   drops.py
           |-- static
           |       favicon.ico
           |       Wassertropfen.JPG
           |-- templates
                  index.html
                  layout.html

So, that’s are all requirements we need.
In the next part I show you the complete program codes of the project.