-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
33 lines (26 loc) · 870 Bytes
/
server.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
import flask
import lipd
import json
from flask import Flask
from flask import send_from_directory
from flask import request
from lipd import readLipd
app = Flask(__name__)
@app.route('/', methods = ['POST'])
def receiveLiPD():
metadata = json.loads(request.files['metadata.json'].read())
parameters = metadata['parameters']
inputs = metadata['inputs']
# read the input lipd files
input_lipds = {}
for input in inputs:
file = request.files[input]
file.save(input)
input_lipds[input] = lipd.readLipd("./" + input)
# here we would pass parameters & input_lipds to the climate model
print(parameters)
print(input_lipds)
# fake NetCDF file that would really come from the climate model
return send_from_directory("./", "test.nc")
# setting the host and port for the server to run on
app.run(host='0.0.0.0', port=80)