Пример #1
0
def client_create():
    if request.method == 'POST':
        data = request.get_json()
        try:
            ClientView.add_client(data)
            response = app.response_class(response=json.dumps(data),
                                          status=201,
                                          mimetype='application/json')
        except Exception as e:
            data = {'exception': str(e)}
            response = app.response_class(response=json.dumps(data),
                                          status=400,
                                          mimetype='application/json')
    return response
Пример #2
0
def transaction_create():
    if request.method == 'POST':
        data = request.get_json()
        try:
            new = AccountTransactionView.add_transaction(data)
            response = app.response_class(response=json.dumps(new),
                                          status=201,
                                          mimetype='application/json')
        except Exception as e:
            data = {'exception': str(e)}
            response = app.response_class(response=json.dumps(data),
                                          status=400,
                                          mimetype='application/json')
    return response
Пример #3
0
def account_detail(identifier):
    account = AccountView.get_account_with_identifier(identifier)
    data = {'type': account.account_type, 'balance': account.balance}
    response = app.response_class(response=json.dumps(data),
                                  status=200,
                                  mimetype='application/json')
    return response
Пример #4
0
def client_detail(identifier):
    client = ClientView.get_client_with_identifier(identifier)
    data = {'name': client.name, 'identifier': client.identifier}
    response = app.response_class(response=json.dumps(data),
                                  status=200,
                                  mimetype='application/json')
    return response
Пример #5
0
def transaction_detail(identifier):
    transaction = AccountTransactionView.get_transaction_with_identifier(
        identifier)
    print("transaction", transaction)
    response = app.response_class(response=json.dumps(transaction),
                                  status=200,
                                  mimetype='application/json')
    return response
Пример #6
0
def get_filelist():
    files_maps = find_maps()
    nest_files_maps = get_nest_maps(files_maps)

    response = app.response_class(
        response=json.dumps(nest_files_maps),
        status=200,
        mimetype='application/json'
    )
    return response
Пример #7
0
def health():
    response = app.response_class(response=json.dumps({'message': 'ok'}),
                                  status=200,
                                  mimetype='application/json')
    return response