from django.shortcuts import render
from django.contrib.auth import authenticate, login, logout

from website.settings import APPLICATION_NAME

# Create your views here.
def index(request):
    context = {
        'title': 'Index',
        'icon': 'home',
        'description': 'Index of ' + APPLICATION_NAME,
        'keywords': 'index',
    }
    return render(request, 'core/index.html', context)

def login(request):
    username = request.POST['username']
    password = request.POST['password']
    user = authenticate(request, username=username, password=password)
    if user is not None:
        login(request, user)

def logout_view(request):
    logout(request)
