Small Python web interface for raspistill to take photos with the RaspberryPi in the browser. I used the pyramid framework for site generation and bootstrap for fancy mobile-first layouts.
For a successful installation you need:
- a RaspberryPi with raspbian installed (other os not tested, but should work too)
- a RaspberryPi Camera Kit
I'll provide a guide to install raspistillWeb based on the tutorial from the pyramid framework to install raspistillWeb in a seperate python environment, so that your systems python environment is not effected.
-
Make sure that your raspbian and your camera is working. Try to make a photo with raspistill to verify that your camera is working.
-
Install python3-dev (if not already on your system), setuptools and exif and virtualenv via pip:
sudo apt-get install python3-dev python3-pip python3-setuptools exif
sudo pip3 install virtualenv
- Create a virtual environment for python (sudo not required and not recommended):
mkdir ~/Development
(Or another directory)cd ~/Development
virtualenv --python=python3 env
cd env
- Install raspistillWeb
git clone https://github.com/TimJuni/raspistillWeb.git
cd raspistillWeb
../bin/python3 setup.py develop
(this may take some time)
- Initialize the database
../bin/initialize_raspistillweb_db development.ini
- Run raspistillWeb
../bin/pserve development.ini
- surf
http://<adress of your pi>:6543
To update your Version of raspistillWeb, simply go into the raspistillWeb Directory and type:
git pull
../bin/python setup.py develop
Please notice, that you may need to install new dependencies (for example exif via apt-get)
If you run raspistillWeb over ssh, you cannot quit your ssh session, because the raspistillWeb process will be killed. One easy way to start raspistillWeb (and let it run even when you are logged off) is to use screen
:
- Install screen
sudo apt-get install screen
- Create a new screen
screen -S cam
- Start raspistillWeb
../bin/pserve development.ini
- Detatch the screen
- simply hit ctrl + a + d
At this point you can quit your ssh session and raspistillWeb will continue serving files. If you later want stop raspistillWeb, you can attach to the screen by: screen -r cam
If you want to use to raspistillWeb from the internet, you can set up an apache reverse proxy to restrict the access to the application. Therefore you have to open port 80 in your router for your pi and follow these instructions:
- Install Apache Web Server
sudo apt-get install apache2
- Enable Apache Proxy Mod
sudo a2enmod proxy_http
- Disable Default Site
sudo a2dissite default
- Create a new Virtualhost
sudo nano /etc/apache2/sites-available/raspistillWeb
and add the following content:
<VirtualHost *:80>
ServerName mydomain.org
<Location />
AuthType Basic
AuthName "raspistillWeb Login"
AuthUserFile /usr/local/passwd/passwords
Require user guest
</Location>
ProxyPreserveHost On
ProxyRequests off
ProxyPass / http://localhost:6543/
ProxyPassReverse / http://localhost:6543/
</VirtualHost>
-
Create a password file
sudo mkdir /usr/local/passwd
sudo htpasswd -c /usr/local/passwd/passwords guest
- Enter a password
-
Enable the Virtualhost and restart the Webserver
sudo a2ensite raspistillWeb
sudo /etc/init.d/apache2 restart
When you surf http://<adress of your pi>
you should be asked for a username (guest) and a password (see step 5).
- Create a startup script
sudo nano /etc/init.d/raspistillweb
#!/bin/bash
cd /home/pi/Development/env/raspistillWeb
../bin/pserve development.ini
- Make the script executable
sudo chmod 755 /etc/init.d/raspistillweb
- Register the script to be run at startup
sudo update-rc.d /etc/init.d/raspistillweb defaults
This is my first project with python and pyramid. Feel free to leave a commend or a feature request.