Commit 3270ef5c by Patryk Czarnik

szablon czasu

parent afeb8d24
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<title>Która godzina</title>
</head>
<body>
<h1>Nagłówek strony</h1>
<p>To jest zwykły tekst.</p>
<p>Teraz jest {{now}}</p>
<p>Dzień miesiąca to {{now.day}} a sekunda {{now.second}}</p>
</body>
</html>
......@@ -10,3 +10,18 @@ def hello(request):
def daj_czas(request):
return HttpResponse(datetime.now())
def czas_html(request):
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 późna godzina <strong style="color:purple">{godzina}</strong></p>
</body>
</html>
'''
return HttpResponse(html, content_type='text/html;charset=UTF-8')
def czas_szablon(request):
return render(request, 'szablon_czasu.html', {'now': datetime.now()})
......@@ -17,10 +17,12 @@ Including another URLconf
from django.contrib import admin
from django.urls import path
from aplikacja.views import hello, daj_czas
from aplikacja.views import *
urlpatterns = [
path("admin/", admin.site.urls),
path("hello", hello),
path("czas", daj_czas),
path("czas1", daj_czas),
path("czas2", czas_html),
path("czas3", czas_szablon),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment