Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_alx_pcz
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
kurs_alx_pcz
Commits
7284e776
Commit
7284e776
authored
Dec 12, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Django - datetime bez szablonu
parent
bc7c778b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
views.py
mojprojekt/aplikacja/views.py
+22
-1
urls.py
mojprojekt/mojprojekt/urls.py
+3
-1
No files found.
mojprojekt/aplikacja/views.py
View file @
7284e776
from
django.http
import
HttpResponse
from
django.http
import
HttpRe
quest
,
HttpRe
sponse
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
datetime
import
datetime
# Create your views here.
# Create your views here.
def
hello
(
request
):
def
hello
(
request
):
return
HttpResponse
(
'Hello <strong style="color:red">Django</strong>!'
)
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
)
mojprojekt/mojprojekt/urls.py
View file @
7284e776
...
@@ -16,9 +16,11 @@ Including another URLconf
...
@@ -16,9 +16,11 @@ Including another URLconf
"""
"""
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
path
from
aplikacja.views
import
hello
from
aplikacja.views
import
*
urlpatterns
=
[
urlpatterns
=
[
path
(
"admin/"
,
admin
.
site
.
urls
),
path
(
"admin/"
,
admin
.
site
.
urls
),
path
(
"hello"
,
hello
),
path
(
"hello"
,
hello
),
path
(
"czas.txt"
,
czas_txt
),
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