Esempio n. 1
0
def new_reply_with_array_obj_input(body):  # noqa: E501
    # 拒絕非認證的來源 refuse user or origin
    Origin = connexion.request.headers["Sec-Fetch-Site"] if "Sec-Fetch-Site" in connexion.request.headers else \
    connexion.request.headers["Origin"] if "Origin" in connexion.request.headers else None
    if Origin != "same-site" and Origin != "same-origin" and Origin != "https://goodclass.cf":
        return {"ERROR": "Unauthorized USER"}, 401, header

    if connexion.request.is_json:
        body_json = connexion.request.get_json()
        body = Comment.from_dict(body_json)  # noqa: E501
        try:
            c = operation()
            comment_id = body_json['comment_id']
            user_memo = body_json['user_memo']

            _ = c.new_reply_byid(comment_id=comment_id, user_memo=user_memo)

            return Message(msg="ok").to_dict(), 200, header
        except Exception as e:
            return Message(
                request_status="error",
                msg="UNKNOWERROR: {}".format(e)).to_dict(), 200, header
    else:
        error_msg = Message(request_status="error",
                            msg="connexion.request.is_json")
        return error_msg.to_dict(), 500, header
Esempio n. 2
0
def update_reply_with_array_obj_input(body):  # noqa: E501
    # 拒絕非認證的來源 refuse user or origin
    Origin = connexion.request.headers["Sec-Fetch-Site"] if "Sec-Fetch-Site" in connexion.request.headers else \
    connexion.request.headers["Origin"] if "Origin" in connexion.request.headers else None
    if Origin != "same-site" and Origin != "same-origin" and Origin != "https://goodclass.cf":
        return {"ERROR": "Unauthorized USER"}, 401, header

    error_msg = Message(request_status="error", msg="NotImplementedError")
    return error_msg.to_dict(), 500, header
def new_class_with_array_obj_input(body):  # noqa: E501
    # 拒絕非認證的來源 refuse user or origin
    Origin = connexion.request.headers["Sec-Fetch-Site"] if "Sec-Fetch-Site" in connexion.request.headers else \
    connexion.request.headers["Origin"] if "Origin" in connexion.request.headers else None
    if Origin != "same-site" and Origin != "same-origin" and Origin != "https://goodclass.cf":
        return {"ERROR": "Unauthorized USER"}, 401, header
    """Info of class

     # noqa: E501

    :param body: Pet object that needs to be added to the store
    :type body: dict | bytes

    :rtype: object
    """
    if connexion.request.is_json:
        body_json = connexion.request.get_json()
        body = Comment.from_dict(body_json)  # noqa: E501
        try:
            c = comment_operation()
            major = body_json[
                'major'] if 'major' in body_json else "這傢伙很懶,什麼都沒有寫"
            midexam = body_json[
                'midexam'] if 'midexam' in body_json else "這傢伙很懶,什麼都沒有寫"
            endexam = body_json[
                'endexam'] if 'endexam' in body_json else "這傢伙很懶,什麼都沒有寫"
            value = body_json[
                'value'] if 'value' in body_json else "這傢伙很懶,什麼都沒有寫"
            cost = body_json['cost'] if 'cost' in body_json else "這傢伙很懶,什麼都沒有寫"
            classcall = body_json[
                'classcall'] if 'classcall' in body_json else 2
            homework = body_json['homework'] if 'homework' in body_json else 2
            classexam = body_json[
                'classexam'] if 'classexam' in body_json else 2
            _ = c.new_comment_byid(body.class_name, body.teacher_name, major,
                                   midexam, endexam, body.user_memo, value,
                                   cost, classcall, homework, classexam)

            return Message(msg="ok").to_dict(), 200, header
        except Exception as e:
            return Message(
                request_status="error",
                msg="UNKNOWERROR: {}".format(e)).to_dict(), 200, header
    else:
        error_msg = Message(request_status="error",
                            msg="connexion.request.is_json")
        return error_msg.to_dict(), 500, header
def update_class_with_array_obj_input(body):  # noqa: E501
    # 拒絕非認證的來源 refuse user or origin
    Origin = connexion.request.headers["Sec-Fetch-Site"] if "Sec-Fetch-Site" in connexion.request.headers else \
    connexion.request.headers["Origin"] if "Origin" in connexion.request.headers else None
    if Origin != "same-site" and Origin != "same-origin" and Origin != "https://goodclass.cf":
        return {"ERROR": "Unauthorized USER"}, 401, header
    """Info of class

     # noqa: E501

    :param body: Pet object that needs to be added to the store
    :type body: dict | bytes

    :rtype: object
    """
    if connexion.request.is_json:
        body = Comment.from_dict(connexion.request.get_json())  # noqa: E501
        return body, 200, header
    else:
        error_msg = Message(request_status="error",
                            msg="connexion.request.is_json")
        return error_msg.to_dict(), 500, header
from swagger_server.models.message import Message

a = Message(request_status="success",msg="hi")
print(a.to_dict())