-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·47 lines (34 loc) · 1.08 KB
/
app.py
File metadata and controls
executable file
·47 lines (34 loc) · 1.08 KB
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
43
44
45
46
47
from flask import Flask, jsonify, request, render_template
import json
app = Flask(__name__)
# -------------------------------- index ------------------------------ #
@app.route('/')
def index():
return render_template('index.html')
# ---------------------------- selected mol --------------------------- #
@app.route('/data')
def get_data_filtered():
mol_list = request.args.getlist('molecule')
with open('data.json', 'r') as f:
data = json.load(f)
result = {}
for city, info in data.items():
coords = info["coords"]
points = info["points"]
# filtrage par molécule
if mol_list:
filtered_points = {
mol: conc
for mol, conc in points.items()
if mol in mol_list
}
else:
filtered_points = points
if filtered_points:
result[city] = {
"coords": coords,
"points": filtered_points
}
return jsonify(data)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)