SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
Picamera, Flask and the Twitter API Raspberry Pi workshop
Picamera, Flask and the Twitter API Raspberry Pi workshop
1.
Raspberry Pi
Creative Technologists
Sheffield
July 2015
2.
Self-directed workshop
● Use the Terminal (command line interface)
● Install software (apt and pip)
● Use the web browser (that's where the good stuff is)
● Use GitHub (download projects, upload your own)
● Use APIs (Application Programming Interfaces)
● Ask questions!
● Take notes!
● Expand your understanding!
● Ask for help!
5.
Test the camera
● raspistill -k
● If it doesn't work, is your camera connected correctly?
● Is your camera enabled?
– sudo raspi-config
– Enable camera
● Press Ctrl + C to exit the preview
6.
Browse my project on GitHub
● Open the web browser
● Go to https://github.com/bennuttall/bett-bot
● Read the instructions
● Do the instructions:
– Install pip
– Install flask
– Download the repo
– Install twython
7.
Run the app
● Enter the bett-bott folder
– cd bett-bott
● Run the app
– python app.py
● Open 127.0.0.1:5000 in the web browser
● Click Capture to take a photo
● See the photo in the gallery
● Click the photo
● Take more photos
●
Find your IP address (e.g. 192.168.1.8)
– hostname -I
● Browse to http://192.168.1.8:5000 on your phone/tablet/laptop
8.
Connect to Twitter
● Log in to www.twitter.com in the web browser (or sign up)
● Go to apps.twitter.com
– Create new app
– Set permissions to read and write
– Generate access tokens
(see Tweeting Babbage resource on raspberrypi.org for
detailed instructions)
– raspberrypi.org/learning/tweeting-babbage/worksheet/
9.
Add your API keys
● Open auth.py with Python/IDLE
● Add your keys
– consumer_key
– consumer_secret
– access_token
– access_token_secret
● Run the app again
– Open Terminal
– cd bett-bot-master
– python app.py
● Now you can tweet the pictures
10.
Look at the code
● Open app.py with Python/IDLE
● What's it doing?
– Imports
– Try/except
– Connect to Twitter
– Define routes
● /
● /capture/
● /view/
● /tweet/
– Routes refer to HTML templates
– Run Flask app
11.
Hack it
● Change the appearance
● Add a feature
● Think about more to do later – ideas?
● Is a web app suitable?
● What's possible? What's not?
● Think about hardware installation
● Think about touch screens
0 likes
Be the first to like this
Views
Total views
1,299
On SlideShare
0
From Embeds
0
Number of Embeds
16
You have now unlocked unlimited access to 20M+ documents!
Unlimited Reading
Learn faster and smarter from top experts
Unlimited Downloading
Download to take your learnings offline and on the go
You also get free access to Scribd!
Instant access to millions of ebooks, audiobooks, magazines, podcasts and more.
Read and listen offline with any device.
Free access to premium services like Tuneln, Mubi and more.