aboutsummaryrefslogtreecommitdiff
path: root/api/user/status.py
blob: 050ed336501a56485d6ffc2c67e0cec75ccc366c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from flask import Blueprint, request
from db import cursor, connection
from hierarchy import auth_required
import json

status = Blueprint('user_status', __name__)


@status.route('/status', methods=['POST'])
@auth_required("user")
def index(user_id):
    data = request.get_json()
    status = data.get("status") or ""
    if not status: return "", 400

    cursor.execute(
        "update users set status = ? where user_id = ?",
        [status[0:200], user_id]
    )
    connection.commit()

    return "", 200


dynamic_route = ["/user", status]