Skip to content

Commit 9073adb

Browse files
committed
step 2 done.
1 parent 0e78231 commit 9073adb

File tree

7 files changed

+225
-4
lines changed

7 files changed

+225
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.python-version
22
.venv
3-
.idea
3+
.idea

page_analyzer/app.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from flask import Flask
2+
from flask import Flask, render_template
33
from dotenv import load_dotenv
44

55
load_dotenv()
@@ -9,7 +9,15 @@
99

1010
@app.route('/')
1111
def index():
12-
return "Hello, World!"
12+
return render_template('index.html')
13+
14+
@app.route('/urls')
15+
def all_urls():
16+
pass
17+
18+
@app.route('/urls', methods=['POST'])
19+
def add_url():
20+
pass
1321

1422
__all__ = ['app']
1523
if __name__ == '__main__':

page_analyzer/templates/index.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{% extends 'layout.html' %}
2+
{% block sidebar %}
3+
{% with messages = get_flashed_messages(with_categories=true) %}
4+
{% if messages %}
5+
<div>
6+
{% for category, message in messages %}
7+
<div class="alert alert-{{ category }}" role="alert">
8+
{{ message }}
9+
</div>
10+
{% endfor %}
11+
</div>
12+
{% endif %}
13+
{% endwith %}
14+
{% endblock sidebar %}
15+
{% block content %}
16+
<!--Главная форма-->
17+
<body>
18+
<div class="container py-3">
19+
<div class="col-12 col-md-11 col-lg-8 mx-auto border rounded-3 bg-light p-5">
20+
<h1 class="display-3">Анализатор страниц</h1>
21+
<p class="lead">Бесплатно проверяйте сайты на SEO-пригодность</p>
22+
<form action="{{ url_for('add_url') }}" method="post" class="d-flex justify-content-center">
23+
<div class="input-group input-group-lg">
24+
<input
25+
type="url"
26+
name="url"
27+
value="{{ url if url is defined else '' }}"
28+
placeholder="https://www.example.com"
29+
class="form-control form-control-lg"
30+
required
31+
>
32+
<input type="submit" value="Проверить" class="btn btn-primary btn-lg ms-3 px-5 text-uppercase mx-2">
33+
</div>
34+
</form>
35+
</div>
36+
</div>
37+
</body>
38+
{% endblock %}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Анализатор страниц</title>
7+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
<!--Шапка страницы-->
11+
<header>
12+
<nav class="navbar navbar-expand-md navbar-dark bg-dark px-1">
13+
<div class="container-fluid">
14+
<a class="navbar-brand" href="{{ url_for('index') }}">Анализатор страниц</a>
15+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Переключатель навигации">
16+
</button>
17+
<div class="collapse navbar-collapse" id="navbarNav">
18+
<ul class="navbar-nav">
19+
<li class="nav-item">
20+
<a class="nav-link active" aria-current="page" href="{{ url_for('all_urls') }}">Сайты</a>
21+
</li>
22+
</ul>
23+
</div>
24+
</div>
25+
</nav>
26+
</header>
27+
{% block sidebar %}{% endblock sidebar %}
28+
<main class="flex-grow-1">
29+
<div id="content" class="container-lg mt-3">
30+
{% block content %}{% endblock %}
31+
</div>
32+
</main>
33+
34+
<!--форма внизу-->
35+
<footer class="text-black p-3 fixed-bottom">
36+
<div class="w-100 border-top border-secondary opacity-25 mb-3"></div>
37+
<div class="container text-center">
38+
<a href="https://ru.hexlet.io/">Hexlet</a>
39+
</div>
40+
</footer>
41+
</body>
42+
</html>

page_analyzer/templates/urls.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% extends 'layout.html' %}
2+
3+
{% block content %}
4+
<div class="container mt-5">
5+
<h1 class="mb-4">Сайты</h1>
6+
<table data-test="urls" class="table table-bordered table-hover">
7+
<thead class="table-light">
8+
<tr>
9+
<th>ID</th>
10+
<th>Имя</th>
11+
<th>Последняя проверка</th>
12+
<th>Код ответа</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
{% for url in urls %}
17+
<tr>
18+
<td>{{ url.id }}</td>
19+
<td><a href="{{ url_for('url_detail', id=url.id) }}">{{ url.name }}</a></td>
20+
<td>{{ url.last_check.strftime('%d-%m-%Y %H:%M') if url.last_check else 'Ещё не проверялся' }}</td>
21+
<td>{{ url.status_code if url.status_code else '' }}</td>
22+
</tr>
23+
{% endfor %}
24+
</tbody>
25+
</table>
26+
</div>
27+
{% endblock %}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ requires-python = ">=3.10"
77
dependencies = [
88
"flask>=3.1.0",
99
"gunicorn>=23.0.0",
10+
"pytest>=8.3.5",
1011
"python-dotenv>=1.1.0",
1112
"ruff>=0.11.7",
1213
]

0 commit comments

Comments
 (0)