-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
d.lassahn
committed
Jun 3, 2018
1 parent
b9ea9eb
commit 8738942
Showing
60 changed files
with
437 additions
and
297 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,55 @@ | ||
from flask import Flask, request | ||
from flask import Flask, request, jsonify | ||
from datetime import datetime | ||
from src.RequestHandler.requestHandler import prepare_data | ||
import json | ||
from config import VALID_API_KEYS | ||
app = Flask(__name__) | ||
|
||
|
||
@app.route('/') | ||
def hello_world(): | ||
return 'Hello World!' | ||
|
||
|
||
@app.route('/request') | ||
def my_route(): | ||
try: | ||
param = { | ||
'destination': request.args.get('destination', default='PALMA_DE_MALLORCA', type=str), | ||
'trip_duration': request.args.get('trip_duration', default=7, type=int), | ||
'start_date': datetime.strptime(request.args['trip_start'], '%Y%m%d'), | ||
'criterion_num_days': request.args.get('criterion_num_days', default=1, type=int), | ||
'criterion_sunshine_day': request.args.get('criterion_sunshine_day', default=5, type=int) | ||
} | ||
except BaseException as e: | ||
return json.dumps(e) | ||
|
||
prob, u = prepare_data(**param) | ||
|
||
return json.dumps({'Probability': prob.values[0], | ||
'Mean of Days criterion is True': u.values[0]}) | ||
if request.args.get('api_key', type=str) in VALID_API_KEYS: | ||
print(request.args.get('trip_duration', type=int)) | ||
try: | ||
param = { | ||
'destination': request.args.get('destination', type=str), | ||
'trip_duration': request.args.get('trip_duration', type=int), | ||
'arrival': datetime.strptime(request.args.get('arrival', type=str), '%Y%m%d'), | ||
'criterion_num_days': request.args.get('criterion_num_days', type=int), | ||
'criterion_sunshine_hours_per_day': request.args.get('criterion_sunshine_hours_per_day', type=int) | ||
} | ||
except BaseException as e: | ||
return jsonify(e) | ||
|
||
prob, u = prepare_data(**param) | ||
|
||
return jsonify({'result': {'probability': {'value': round(prob.values[0], 2), | ||
'unit': '%', | ||
'type': 'float'}, | ||
'Mean number of days where criterion is True in hist.Dataset': {'value': u.values[0], | ||
'unit': 'days', | ||
'type': 'float'}}, | ||
'request': {'destination': {'value': param['destination'], | ||
'unit': 'None', | ||
'type': 'str'}, | ||
'trip_duration': {'value': param['trip_duration'], | ||
'unit': 'days', | ||
'type': 'int'}, | ||
'arrival': {'value': param['arrival'].strftime('%Y%m%d'), | ||
'unit': 'date', | ||
'type': 'datetime'}, | ||
'criterion_num_days': {'value': param['criterion_num_days'], | ||
'unit': 'days', | ||
'type': 'int'}, | ||
'criterion_sunshine_hours_per_day': {'value': param['criterion_sunshine_hours_per_day'], | ||
'unit': 'hours', | ||
'type': 'int'}}}) | ||
else: | ||
return jsonify('Wrong Api-key, please contact: [email protected]') | ||
|
||
|
||
if __name__ == '__main__': | ||
|
Empty file.
Empty file.
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/colorize.js
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/colorize.min.js
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/container.css
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/container.min.css
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/embed.css
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/embed.js
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/embed.min.css
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/embed.min.js
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/visit.js
100644 → 100755
Empty file.
Empty file modified
0
src/RestAPI/templates/Semantic-UI-CSS-master/components/visit.min.js
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.