Files @ 1963e193d7ca
Branch filter:

Location: C3L-NOC/spaceapi/spaceapi/state.py

Dennis Fink
Move state set into ActiveStatus
import json

from time import time

from flask import Blueprint, jsonify, request, current_app, abort

import tweepy

from .utils import ActiveStatus
from .auth import httpauth

state_views = Blueprint('state', __name__)


@state_views.route('/set/<key>', methods=['POST'])
@httpauth.login_required
def set_state(key):
    active = ActiveStatus()
    value = json.loads(request.data.decode('utf-8'))['value']
    current_app.logger.info(value)
    current_app.logger.info(type(value))
    active.set_new_state(**{key: value})
    active.save_last_state()
    return jsonify(active)