from django.http import HttpResponse

from .models import Question


def index(request) -> HttpResponse:
    latest_question_list = Question.objects.order_by("-pub_date")[:5]
    output = ", ".join([q.question_text for q in latest_question_list])
    return HttpResponse(output.encode())


def detail(request, question_id) -> HttpResponse:
    _ = request
    return HttpResponse(f"You're looking at question {question_id}.".encode())


def results(request, question_id) -> HttpResponse:
    _ = request
    return HttpResponse(
        f"You're looking at the results of question {question_id}".encode()
    )


def vote(request, question_id) -> HttpResponse:
    _ = request
    return HttpResponse(f"You're voting on question {question_id}".encode())
