Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python_django_2025
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
python_django_2025
Commits
59bc72b1
Commit
59bc72b1
authored
May 15, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
odczyt czasu - wersja html
parent
e7b03705
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
views.py
aplikacja/views.py
+14
-4
urls.py
webowy/urls.py
+2
-2
No files found.
aplikacja/views.py
View file @
59bc72b1
...
...
@@ -8,10 +8,20 @@ from datetime import datetime
def
hello
(
request
):
return
HttpResponse
(
'Hello world'
)
# Dopisz funkcję, która zwraca bieżący czas
def
podaj_czas
(
request
):
dt
=
datetime
.
now
()
return
HttpResponse
(
dt
)
return
HttpResponse
(
dt
,
content_type
=
'text/plain;charset=UTF-8'
)
# uwzględnij tę funkcję w urls
# i przetestuj w przeglądarce
# prosty sposób, aby zwrócić treść w formacie HTML
# po prostu tworzymy HTML w funkcji Pythona i wstawiamy do HttpResponse
def
czas_html
(
request
):
godzina
=
datetime
.
now
()
.
strftime
(
'
%
H:
%
M:
%
S'
)
html
=
f
'''<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'
)
webowy/urls.py
View file @
59bc72b1
...
...
@@ -18,11 +18,11 @@ Including another URLconf
from
django.contrib
import
admin
from
django.urls
import
path
from
aplikacja.views
import
hello
from
aplikacja.views
import
podaj_czas
from
aplikacja.views
import
*
urlpatterns
=
[
path
(
"admin/"
,
admin
.
site
.
urls
),
path
(
"hello"
,
hello
),
path
(
"czas"
,
podaj_czas
),
path
(
"czas_html"
,
czas_html
),
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment