RESTful API with Flask that serves images from Raspberry Pi powered by picamera.
This software is tested in the following environment:
- Raspberry Pi 3 Model B v1.2
- Picamera vX.Y
All dependencies are specified in requirements.txt. Install all python packages:
pip install -r requirements.txt
- If using
virtualenvwrapper:workon WatcherEye - Set Flask app environment variable:
export FLASK_APP=watchereye - Set Flask app development variable:
export FLASK_ENV=info - Start the Flask server:
flask run - Point your favorite browser to
localhost:5000
The API can be accessed via HTTP/S requests, see watchereye/api.pyfor up-to-date API endpoint documentation. Briefly:
| Method | Endpoint | Description | Return Format |
|---|---|---|---|
GET |
/api/v1/ping |
Ping API server | JSON array |
GET |
/api/v1/stats |
Usage statistics | JSON array |
GET |
/api/v1/image |
Capture and return image | image/jpeg |
GET |
/api/v1/stream |
View video stream | multipart/x-mixed-replace; image/jpeg |
Logging at the debug level (recording all incoming requests and IPs) using the default python logging facility. Logs are stored in logs/log.log and streamed to STDOUT
Using PyTest:
workon WatcherEyepython -m pytest -s -v --disable-pytest-warnings tests/
- Installing Raspbian on Raspberry Pi on Mac OS X
- Video Streaming with Flask
- Flask Video Streaming Revisited
Update requirements.txt after installing any new pip modules using:
pip freeze > requirements.txt