Skip to content

spontit/fivethirtyeight-push-notifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FiveThirtyEight Poll Push Notifications

Uses the Spontit API to send push notification updates on FiveThirtyEight poll changes.

Check out the Spontit API to send flexible and functional push notifications to iOS, Android, and Desktop devices for free. For this example, all you need is a secret key and a username, which you can get at spontit.com/secret_keys.

You have to create a channel called "538 Updates" for your account first. You can do this by creating one using the iOS App or by following the "create_new_channel_and_push_to_it" example located here.

To follow the hosted channel, go to spontit.com/liveupdates/538updates. You can view your own channel link by using the get_invite_options function in SpontitResource. To see how to use it, import SpontitResource (from spontit import SpontitResource) and then run the python command help(SpontitResource).

Once you get it working, you should see something like this.

Image of 538 Poll Notification

Run Locally

To run locally, simply run the program and it should work. Not a great long-term solution though.

Run on an EC2 Server

Running it on a server will make the program run as long as you'd like.

First, start an EC2 instance and get your PEM keys.

Copy the main.py from our repo into your server. Make sure it works locally first.

scp -i /path/to/your/server_keys.pem /path/to/the/clone/repo/main.py ec2-user@ec2-ip-address.amzon-region.compute.amazonaws.com:/home/ec2-user

SSH into your server.

ssh -i /path/to/your/server_keys.pem ec2-user@ec2-ip-address.amzon-region.compute.amazonaws.com:/home/ec2-user

Use tmux to run your program in the background and leave it running after you exit.

tmux attach

Run the program after attaching via tmux.

python3 main.py

To exit tmux without stopping the program, press the following command. For me, it normally takes about 10 times before I get this command to work, but it does work!

Control B + D