-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
26 lines (21 loc) · 850 Bytes
/
server.py
File metadata and controls
26 lines (21 loc) · 850 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
# importing the libraries and functions needed
import flask
import lipd
from flask import Flask
from flask import send_from_directory
from flask import request
from lipd import readLipd
app = Flask(__name__)
# setting the route pf the server
@app.route('/', methods = ['POST'])
def receiveLiPD():
# setting the files from the POST request equal to a variable
fileReceived = request.files['pond']
# saving the file locally in order to read it
fileReceived.save('pond.lpd')
# reading the locally saved pond file
readFile = lipd.readLipd("C:/Users/Golde/PycharmProjects/FlaskLibrary/pond.lpd")
# returning the netCDF file from the resulting climate model
return send_from_directory("./", "test.nc")
# setting the host and port for the server to run on
app.run(host='127.0.0.1', port=23657)