Created
July 9, 2020 06:02
-
-
Save HarshCasper/cbe8220b8744c6092eeeba7f1f5bd5c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/givememe/<int:c>') | |
def multiple(c): | |
sub = random.choice(randommeme) | |
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