Skip to content
Snippets Groups Projects
Commit 1ca7fbfa authored by Clemens Berteld's avatar Clemens Berteld
Browse files

Better statistic calculations

parent 09d8db00
No related branches found
No related tags found
No related merge requests found
import json
import psycopg2
from flask import Flask, jsonify, request, send_from_directory
# from flask_cors import cross_origin
from flask_cors import cross_origin
from psycopg2 import sql
import configparser
from GetAverageData import get_interpolation_data_for_point, get_year_columns, get_average_of_multiple_years, get_min_max
......@@ -20,7 +20,7 @@ app.config['TESTING'] = False
@app.route('/', methods=['GET'])
# @cross_origin()
@cross_origin()
def index():
columns = sql.SQL(' * ') # columns to be queried (e.g. years)
wheres = sql.SQL('') # where filters
......@@ -122,22 +122,22 @@ def get_raster():
return send_from_directory(path, filename=filename, as_attachment=True)
# return 'Läuft, Brudi'
# @app.route('/annualMean', methods=['GET'])
# @cross_origin()
# def annualMean():
#
# query = getStandardQuery()
#
# with psycopg2.connect(database=param_postgres["dbName"], user=param_postgres["user"], password=param_postgres["password"], host=param_postgres["host"], port=param_postgres["port"]) as connection:
# with connection.cursor() as cursor:
#
# cursor.execute(query)
#
# results = cursor.fetchall()[0][0]
#
# return jsonify(s2pTool.determineAnnualMean(results))
#
# return "{}"
@app.route('/annualMean', methods=['GET'])
@cross_origin()
def annualMean():
query = getStandardQuery()
with psycopg2.connect(database=param_postgres["dbName"], user=param_postgres["user"], password=param_postgres["password"], host=param_postgres["host"], port=param_postgres["port"]) as connection:
with connection.cursor() as cursor:
cursor.execute(query)
results = cursor.fetchall()[0][0]
return jsonify(s2pTool.determineAnnualMean(results))
return "{}"
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment