Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Temperaturverteilung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s39174
Temperaturverteilung
Commits
1ca7fbfa
Commit
1ca7fbfa
authored
3 years ago
by
Clemens Berteld
Browse files
Options
Downloads
Patches
Plain Diff
Better statistic calculations
parent
09d8db00
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/api.py
+18
-18
18 additions, 18 deletions
api/api.py
with
18 additions
and
18 deletions
api/api.py
+
18
−
18
View file @
1ca7fbfa
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__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment