-
Notifications
You must be signed in to change notification settings - Fork 0
/
flak.py
31 lines (24 loc) · 839 Bytes
/
flak.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
#!usr/bin/python
from flask import Flask,jsonify,render_template,request
import urllib2
import xmltodict,json
from cricbuzz import CricbuzzParser
from werkzeug.contrib.cache import SimpleCache
app=Flask(__name__)
cache=SimpleCache()
@app.route('/_get_scores')
def get_scores():
o=cache.get('scores')
if o is None:
cric = CricbuzzParser()
match = cric.getJson()
details = cric.handleMatches(match) #Returns Match details as a Dictionary. Parse it according to requirements.
o={'details':details}
cache.set('scores',o,timeout=15)
return app.response_class(json.dumps(o,
indent=None if request.is_xhr else 2), mimetype='application/json')
@app.route('/')
def index():
return render_template('index.html')
if __name__=="__main__":
app.run(host='0.0.0.0',port=8080,debug=False)