-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver-text.py
More file actions
33 lines (28 loc) · 953 Bytes
/
server-text.py
File metadata and controls
33 lines (28 loc) · 953 Bytes
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
#!/usr/bin/python
from flask import Flask
import json
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.route("/search/<int:corde>/<int:tpstotal>")
def search(corde,tpstotal):
out=[]
print 'lendata',len(data)
for itm in data:
#print itm['corde']
if itm.has_key('tpstotal'):
print itm['tpstotal']
if itm.has_key('tpstotal') and itm['tpstotal']<=3600*int(tpstotal) and itm['corde']<=int(corde)/2:
out.append(itm)
out.sort(key=lambda itm:itm['interet'],reverse=True)
#cur = client['canyons']['canyons'].find({'tpstotal':{'$lte':3600*int(tpstotal)},'corde':{'$lte':int(corde)/2}},{"_id":0}).sort('interet',-1)
#for itm in cur:
# out.append(itm)
print str(out)
return json.dumps(out)
if __name__ == "__main__":
f = open('canyons.json','r')
data = json.load(f)
f.close()
app.run(host='localhost',port=30000,debug=True)