The more you Yo, the more you'll know!
We're running this awesome Yo challenge, so I thought I'd give it a shot. I cloned the BarRecommender App and stripped it down to basics.
Routes
/
— the landing page/yo/
— the main endpoint. When a user sends a Yo to GITATME, the server sends back a link to a random issue of my open source newsletter Git@Me. Bonus: once you add GITATME - you'll get a Yo whenever I publish a new issue.
Making the magic
The Yo API is super easy to use with Python & Requests:
import requests
token = 'your_api_key'
username = request.args.get('username')
url = 'http://foo.bar'
requests.post("http://api.justyo.co/yo/", data={'api_token': token, 'username': username, 'link': url})
All I really had to do was tell Feedparser to pull all the link
entries from my Atom feed and pick one at random:
import feedparser
import random
f = feedparser.parse('http://gitat.me/rss.xml')
seed = random.randint(0,len(f['entries'])-1)
url = f['entries'][seed]['link']
Yo, it's that simple.
Log in or sign up for Devpost to join the conversation.