This commit is contained in:
Viktor Søndergaard 2019-04-06 18:41:03 +02:00
commit b7d7cbcdb3

View File

@ -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():