-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenAvis.py
31 lines (25 loc) · 876 Bytes
/
enAvis.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
from flask import Flask
from flask import render_template
from pymongo import MongoClient
import json
from bson import json_util
from bson.json_util import dumps
app = Flask(__name__)
URI = 'mongodb://demo:[email protected]:36638/enavis'
FIELDS = {'dept': True, 'tot_gpa': True, 'decision': True, 'year': True, 'gender': True, 'enrolled': True}
@app.route("/")
def index():
return render_template('index.html')
@app.route("/database/request")
def request_data():
c = MongoClient(URI)
collection = c.enavis.core
applicants = collection.find(fields=FIELDS)
json_projects = []
for applicant in applicants:
json_projects.append(applicant)
json_projects = json.dumps(json_projects, default=json_util.default)
c.disconnect()
return json_projects
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000, debug=True)