-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
33 lines (29 loc) · 1.04 KB
/
setup.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
from flask import Flask, render_template, request
import requests as req
from time import strftime
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def inicio():
if request.method == 'POST':
nome = request.form['nome']
obj_dict = req.get('https://api.github.com/users/%s' % nome)
dict_ = dict(obj_dict.json())
try:
repos = req.get(dict_['repos_url'])
dict_['repos'] = repos.json()
except:
pass
try:
seguindo = req.get(dict_['following_url'])
seguidor = req.get(dict_['followers_url'])
dict_['seguindo'] = seguindo.json()
dict_['seguidor'] = seguidor.json()
except:
pass
try:
if dict_['message'] == 'Not Found':
msg = dict({'msg': 'perfil não encontrado!'})
return render_template('index.html', msg=msg)
except:
return render_template('index.html', dict_=dict_)
return render_template('index.html')