From e809c1ccd2a17503eb314904d4f37a364a29dc4f Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Sat, 6 Apr 2019 18:07:10 +0200 Subject: [PATCH] Log POST requests. --- server/nightr/app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/nightr/app.py b/server/nightr/app.py index 3f8b923..f1f534e 100644 --- a/server/nightr/app.py +++ b/server/nightr/app.py @@ -1,4 +1,5 @@ import inspect +import json import statistics import timeit from dataclasses import asdict @@ -7,7 +8,7 @@ from logging import DEBUG from typing import List import requests_cache -from flask import Flask, jsonify, logging +from flask import Flask, jsonify, logging, request from .strategies import miloStrats, iss, cars_in_traffic, tide_strat, upstairs_neighbour from .util import Context @@ -33,8 +34,10 @@ strategies = { @app.route("/", methods=["GET", "POST"]) def probabilities(): - phone_data = {} # TODO: get from POST request + phone_data = request.get_json(force=True) context = Context(**phone_data) + logger.debug("phone_data:\n%s", json.dumps(phone_data, indent=2)) + logger.debug("Context: %s", context) predictions: List[dict] = [] for name, strategy in strategies.items():