Skip to content

Instantly share code, notes, and snippets.

@HarshCasper
Created July 9, 2020 06:12
Show Gist options
  • Save HarshCasper/aec645923796a8849000b9a1a1a861fb to your computer and use it in GitHub Desktop.
Save HarshCasper/aec645923796a8849000b9a1a1a861fb to your computer and use it in GitHub Desktop.
@app.route('/givememe/<sub>/<int:c>')
def multiple_from_sub(sub, c):
if c >= 50:
return jsonify({
'status_code': 400,
'message': 'Ensure that the Count is less than 50'
})
requested = get_meme(sub, 100)
random.shuffle(requested)
memes = []
for post in requested:
if check_image(post["Url"]) and len(memes) != c:
t = {
'Title': post["Title"],
'Url': post["Url"],
'Upvotes': post["Upvotes"],
'Downvotes': post["Downvotes"],
'Redditurl': post["Redditurl"],
'Subreddit': post["Subreddit"]
}
memes.append(t)
return jsonify({
'memes': memes,
'count': len(memes)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment