def getAll(request):
  data = postgres_lib.connect('allUsers')
  return Response({
    'status': 200,
    'message': 'OK',
    'data': data,
  })
def get(request, id):
  data = postgres_lib.connect('user', id=id)
  if len(data) == 0:
    return Response({
      'status': 400,
      'message': 'Bad Request',
      'data': data,
    })
  return Response({
    'status': 200,
    'message': 'OK',
    'data': data,
  })
def getInfo(request, id):
  data = postgres_lib.connect('courseInfo', id=id)
  # print('---------------------')
  # print(data)
  if len(data) == 0:
    return Response({
      'status': 400,
      'message': 'Bad Request',
      'data': data,
    })
  return Response({
    'status': 200,
    'message': 'OK',
    'data': data,
  })
def signin(request, username, password):
  data = postgres_lib.connect('signin')
  for i in data:
    if i['username'] == username and i['password'] == password:
      return Response({
        'status': 200,
        'message': 'OK',
        'data': i
      })
  return Response({
      'status': 401,
      'message': 'Unauthorized',
      'data': {}
    })

  return Response({
    'status': 401,
    'message': 'Unauthorized',
    'data': {},
  })