コード例 #1
0
ファイル: server.py プロジェクト: tuzhucheng/HTN2015
def get_sleep(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        return jsonify({'timestamps': []}), http_status

    timestamps_list = [ts['timestamp'] for ts in timestamps]
    sleep = compute_sleep_time(timestamps_list)

    return jsonify({'sleep': sleep}), http_status
コード例 #2
0
ファイル: server.py プロジェクト: luckytoilet/HTN2015
def get_sleep(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        return jsonify({'timestamps': []}), http_status

    timestamps_list = [ts['timestamp'] for ts in timestamps]
    sleep = compute_sleep_time(timestamps_list)

    return jsonify({'sleep': sleep}), http_status
コード例 #3
0
ファイル: server.py プロジェクト: tuzhucheng/HTN2015
def get_timestamps(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        timestamps = []
    return jsonify({'timestamps': timestamps}), http_status
コード例 #4
0
ファイル: server.py プロジェクト: tuzhucheng/HTN2015
def upload_timestamps(username):
    timestamps = request.get_json(force=True)
    status, message = Timestamps.upload(username, timestamps)
    http_status = 200 if status else 400
    return message, http_status
コード例 #5
0
ファイル: server.py プロジェクト: luckytoilet/HTN2015
def get_timestamps(username):
    timestamps = Timestamps.get_timestamps(username)
    http_status = 200 if timestamps else 404
    if timestamps is None:
        timestamps = []
    return jsonify({'timestamps': timestamps}), http_status
コード例 #6
0
ファイル: server.py プロジェクト: luckytoilet/HTN2015
def upload_timestamps(username):
    timestamps = request.get_json(force=True)
    status, message = Timestamps.upload(username, timestamps)
    http_status = 200 if status else 400
    return message, http_status