Created
July 9, 2020 05:48
-
-
Save HarshCasper/dde166207f90e056d2941513d13a701e 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/<sub>') | |
def custom_meme(sub): | |
try: | |
r = get_meme(sub,100) | |
except: | |
return jsonify({ | |
'Status_code': 404, | |
'Message': 'Invalid Subreddit' | |
}) | |
requsted = random.choice(r) | |
while not check_image(requsted["Url"]): | |
count=count+1 | |
requsted = random.choice(r) | |
if count == 100: | |
break | |
return jsonify({ | |
'Title':requsted["Title"], | |
'Url': requsted["Url"], | |
'Upvotes': requsted["Upvotes"], | |
'Downvotes': requsted["Downvotes"], | |
'Redditurl': requsted["Redditurl"], | |
'Subreddit': requsted["Subreddit"] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment