-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (28 loc) · 817 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from flask import Flask
from flask import jsonify
import Instagram
import random as rd
import logging
import sys
app = Flask(__name__)
app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)
@app.route("/instagram")
def getInstaMeme():
posts = Instagram.InstagramCrawler()
postsDetails = posts.results
postsDetail: dict = postsDetails[0]
memes = []
for _ in postsDetail.values():
memes.extend(_)
meme = memes[rd.randint(0, len(memes)-1)]
return jsonify(meme)
@app.route("/reddit")
def getHello():
return jsonify({"hello": "world"})
@app.errorhandler(404)
@app.route('/<lol>')
def not_found(lol):
return "<h1>Oops, I guess You are Lost?</h1>"
if __name__ == '__main__':
app.run(debug=True)