-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
34 lines (29 loc) · 952 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
from flask import Flask,request,render_template,g
import requests
import json
import collections
"""
Run : sudo ~/elasticsearch-1.7.2/bin/elasticsearch
"""
app = Flask(__name__)
from query.details import details_module
app.register_blueprint(details_module)
@app.route('/', methods=['GET'])
def index():
if request.method == 'GET':
r = requests.get("http://localhost:9200/_mapping")
indexData = json.loads(r.text)
indices = {}
for indexName in indexData:
d = {}
for doctype in indexData[indexName]["mappings"]:
r = requests.get("http://localhost:9200/"+indexName+"/"+doctype+"/_count")
count = (json.loads(r.text))["count"]
d[doctype] = count
indices[indexName] = collections.OrderedDict()
for key in sorted(d):
indices[indexName][key] = d[key]
indices = dict(sorted(indices.iteritems()))
return render_template('index.html',indices=indices)
if __name__ == '__main__':
app.run(host='0.0.0.0',port=5001)