from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from datetime import datetime

# Create your views here.
def hello(request):
    return HttpResponse('Hello <strong style="color:red">Django</strong>!')


def czas_txt(request):
    return HttpResponse(str(datetime.now()))


def czas_html(request:HttpRequest) -> HttpResponse:
    godzina = datetime.now().strftime('%H:%M:%S')
    html = f'''<!DOCTYPE html>
<html><head>
<title>Która godzina</title>
</head>
<body style="background-color: #FFFFDD">
<p>Teraz jest godzina <strong style="color:purple">{godzina}</strong></p>
</body>
</html>
'''
    return HttpResponse(html)


def czas_szablon(request:HttpRequest) -> HttpResponse:
    godzina = datetime.now().strftime('%H:%M:%S')
    return render(request=request,
                  template_name='szablon_dla_czasu.html',
                  context={'godz': godzina})


def index(request:HttpRequest) -> HttpResponse:
    return render(request=request, template_name='index.html')

