Skip to content

Instantly share code, notes, and snippets.

/main.py Secret

Created February 20, 2017 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/228a37baed04cf71594e0bb51a34aa21 to your computer and use it in GitHub Desktop.
Save anonymous/228a37baed04cf71594e0bb51a34aa21 to your computer and use it in GitHub Desktop.
days until election
import datetime
import webapp2
import time
import sys
import twython
from twython import Twython, TwythonError
class DaysUntil(webapp2.RequestHandler):
def get(self)
CONSUMER_KEY = ‘???’
CONSUMER_SECRET = ‘???’
ACCESS_KEY = ‘???’
ACCESS_SECRET = ‘???’
from datetime import *
today = date.today()
future = date(2018,11,5)
diff = future - today
NUMBER = diff.days
twitter = twython.Twython(
CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_KEY,
ACCESS_SECRET
)
photo = open("%s.jpg" %NUMBER,'rb')
response = twitter.upload_media(media=photo)
twitter.update_status(status="%s days until the United States Midterm Elections on November 6th, 2018. #election2018 #campaign2018 #politics" %NUMBER, media_ids=[response['media_id']])
app = webapp2.WSGIApplication(['/', DaysUntill])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment