forked from SubhrajitPrusty/codex-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
42 lines (27 loc) · 887 Bytes
/
app.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
37
38
39
40
41
42
from flask import Flask, url_for, render_template
import json
import os
from gevent.pywsgi import WSGIServer
from pymongo import MongoClient
from dotenv import load_dotenv
load_dotenv()
def getContent():
dburl = os.environ.get('MONGODB_URI')
client = MongoClient(dburl)
db = client.get_default_database()
members = db.members
data = []
for mem in members.find():
data.append(mem)
data = sorted(data, key=lambda k: k['totalCommits'])
return data[::-1]
app = Flask(__name__, static_url_path='/static')
@app.route("/")
def index():
content = getContent()
total = sum([x['totalCommits'] for x in content])
return render_template('index.html', context=content, totalC=total)
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
http_server = WSGIServer(('', port), app)
http_server.serve_forever()