|
After Width: | Height: | Size: 442 KiB |
|
After Width: | Height: | Size: 439 KiB |
|
After Width: | Height: | Size: 146 KiB |
|
After Width: | Height: | Size: 147 KiB |
|
After Width: | Height: | Size: 398 KiB |
|
After Width: | Height: | Size: 512 KiB |
|
After Width: | Height: | Size: 337 KiB |
|
After Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 355 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
@@ -7,14 +7,13 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<table>
|
{% for time, file_path in data %}
|
||||||
{% for i in list %}
|
<div>
|
||||||
<tr>
|
<div style="height: 32px;">
|
||||||
<th>{{ i }}</th>
|
<span itemprop="name">{{ time }}</span>
|
||||||
<th>{{ i }}</th>
|
</div>
|
||||||
</tr>
|
<img itemprop="image" alt="name to be replaced" src="{% static file_path %}" width=500px>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,10 +1,23 @@
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
import psycopg2
|
||||||
|
def execute_request(request):
|
||||||
|
connection = psycopg2.connect(host='localhost', dbname='dbdata',
|
||||||
|
user='postgres', password='Q1w2e3r4')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute(request)
|
||||||
|
result = cursor.fetchall()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
return result
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"text": "test",
|
"data": execute_request("select name, link from parsing")[:10]
|
||||||
"list": [0, 1, 2, 3, "frogg"]
|
|
||||||
}
|
}
|
||||||
|
for i in range(len(context["data"])):
|
||||||
|
context["data"][i] = list(context["data"][i])
|
||||||
|
context["data"][i][1] = f"polls/img/{i}.jpg"
|
||||||
|
|
||||||
return HttpResponse(render(request, "polls/index.html", context))
|
return HttpResponse(render(request, "polls/index.html", context))
|
||||||
|
|||||||