Push notifications from Python to Phone using pushover

If something strange happens on your server or in your python-app you may want to send a push notification. I chose pushover for this.

Create an app here: https://pushover.net/apps/build.

Your usertoken is on your dashboard mainpage in pushover.

The script needs requests.

import requests
import sys

r = requests.post("https://api.pushover.net/1/messages.json",
                  data={'token': 'APP_TOKEN',
                        'user': 'USER_KEY',
                        'message': u' '.join(sys.argv[1:])})

This can now be called for example like this:

python pushover.py This is my message!

I use this on error in cronjobs for private projects.

Comments