This commit is contained in:
EDeev 2026-02-13 17:56:27 +03:00
parent 6fae44acef
commit 05c84095a7
17 changed files with 1212 additions and 0 deletions

107
labs/lab-2/app/app.py Normal file
View file

@ -0,0 +1,107 @@
import re
import random
from flask import Flask, render_template, request
from faker import Faker
fake = Faker('ru_RU')
app = Flask(__name__)
application = app
images_ids = ['Pic1', 'Pic2', 'Pic3', 'Pic4', 'Pic5']
def generate_comments(replies=True):
comments = []
for i in range(random.randint(1, 3)):
comment = { 'author': fake.name(), 'text': fake.text() }
if replies:
comment['replies'] = generate_comments(replies=False)
comments.append(comment)
return comments
def generate_post(i):
return {
'title': fake.company(),
'text': fake.paragraph(nb_sentences=100),
'author': fake.name(),
'date': fake.date_time_between(start_date='-2y', end_date='now'),
'image_id': f'{images_ids[i]}.jpg',
'comments': generate_comments()
}
posts_list = sorted([generate_post(i) for i in range(5)], key=lambda p: p['date'], reverse=True)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/posts')
def posts():
return render_template('posts.html', title='Посты', posts=posts_list)
@app.route('/posts/<int:index>')
def post(index):
p = posts_list[index]
return render_template('post.html', title=p['title'], post=p)
@app.route('/about')
def about():
return render_template('about.html', title='Об авторе')
@app.route('/login', methods=['GET', 'POST'])
def login():
form_data = None
if request.method == 'POST':
form_data = {
'login': request.form.get('login', ''),
'password': request.form.get('password', '')
}
return render_template(
'request_data.html',
title='Данные запроса',
url_params=request.args,
headers=request.headers,
cookies=request.cookies,
form_data=form_data
)
def validate_phone(phone):
allowed = set('0123456789 ()-.+')
for ch in phone:
if ch not in allowed:
return None, 'Недопустимый ввод. В номере телефона встречаются недопустимые символы.'
digits = re.sub(r'\D', '', phone)
stripped = phone.strip()
if stripped.startswith('+7') or stripped.startswith('8'):
if len(digits) != 11:
return None, 'Недопустимый ввод. Неверное количество цифр.'
else:
if len(digits) != 10:
return None, 'Недопустимый ввод. Неверное количество цифр.'
if len(digits) == 11:
digits = digits[1:]
formatted = f'8-{digits[0:3]}-{digits[3:6]}-{digits[6:8]}-{digits[8:10]}'
return formatted, None
@app.route('/phone', methods=['GET', 'POST'])
def phone():
error = None
formatted_phone = None
phone_value = ''
if request.method == 'POST':
phone_value = request.form.get('phone', '')
formatted_phone, error = validate_phone(phone_value)
return render_template(
'phone.html',
title='Проверка номера телефона',
error=error,
formatted_phone=formatted_phone,
phone_value=phone_value
)
if __name__ == '__main__':
app.run(debug=True)

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View file

@ -0,0 +1,697 @@
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@400;600;700&family=Inter:wght@400;500;600&display=swap');
:root {
--primary: #e63946;
--primary-light: #ff6b6b;
--primary-dark: #c1121f;
--primary-bg: rgba(230, 57, 70, 0.15);
--primary-glow: rgba(230, 57, 70, 0.3);
--bg-main: #0d0d0d;
--bg-darker: #080808;
--bg-card: #141414;
--bg-card-hover: #1a1a1a;
--bg-elevated: #1e1e1e;
--bg-input: #1a1a1a;
--text-primary: #ffffff;
--text-secondary: #b0b0b0;
--text-muted: #666666;
--border: #2a2a2a;
--border-light: #3a3a3a;
--success: #22c55e;
--error: #ef4444;
--radius-sm: 8px;
--radius-md: 12px;
--radius-lg: 16px;
--radius-xl: 24px;
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
font-size: 16px;
line-height: 1.6;
color: var(--text-secondary);
background-color: var(--bg-main);
-webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Raleway', sans-serif;
font-weight: 700;
line-height: 1.2;
letter-spacing: -0.02em;
color: var(--text-primary);
}
h1 { font-size: clamp(2rem, 4vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
a {
color: var(--primary);
text-decoration: none;
transition: var(--transition);
}
a:hover {
color: var(--primary-light);
}
::selection {
background: var(--primary);
color: white;
}
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--primary);
}
/* ===== NAVBAR ===== */
.navbar {
background: rgba(13, 13, 13, 0.8) !important;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border-bottom: 1px solid var(--border);
padding: 1rem 0;
transition: var(--transition);
}
.navbar-brand {
font-family: 'Raleway', sans-serif;
font-weight: 700;
color: var(--text-primary) !important;
font-size: 1.1rem;
}
.navbar-brand:hover {
color: var(--primary) !important;
}
.navbar .nav-link {
color: var(--text-secondary) !important;
font-weight: 500;
font-size: 0.9rem;
padding: 0.5rem 1rem !important;
border-radius: var(--radius-sm);
transition: var(--transition);
}
.navbar .nav-link:hover {
color: var(--text-primary) !important;
background: var(--primary-bg);
}
.navbar .nav-link.active {
color: var(--primary) !important;
background: var(--primary-bg);
}
.navbar-toggler {
border-color: var(--border) !important;
}
.navbar-toggler-icon {
filter: invert(1);
}
/* ===== MAIN CONTAINER ===== */
.container {
max-width: 1200px;
}
main.my-3 {
padding-top: 2rem;
padding-bottom: 2rem;
}
/* ===== CARDS (posts list) ===== */
.card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
overflow: hidden;
transition: var(--transition);
width: 100%;
}
.card:hover {
border-color: var(--border-light);
transform: translateY(-2px);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.card-img-top {
aspect-ratio: 16/9;
object-fit: cover;
border-radius: 0;
}
.card-body {
padding: 1.5rem;
}
.card-title {
margin-bottom: 0.75rem;
font-size: 1.25rem;
}
.card-text {
color: var(--text-secondary);
font-size: 0.95rem;
margin-bottom: 1rem;
}
.card-footer {
background: transparent;
border-top: 1px solid var(--border);
color: var(--text-muted) !important;
padding: 1rem 1.5rem;
font-size: 0.85rem;
}
/* ===== BUTTONS ===== */
.btn-primary {
display: inline-flex;
align-items: center;
padding: 0.75rem 1.5rem;
font-weight: 600;
font-size: 0.9rem;
border-radius: var(--radius-md);
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
border: none;
color: white;
box-shadow: 0 4px 15px var(--primary-glow);
transition: var(--transition);
cursor: pointer;
}
.btn-primary:hover,
.btn-primary:focus {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(230, 57, 70, 0.4);
background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
border: none;
}
.btn-outline {
display: inline-flex;
align-items: center;
padding: 0.75rem 1.5rem;
font-weight: 600;
font-size: 0.9rem;
border-radius: var(--radius-md);
background: transparent;
border: 2px solid var(--border-light);
color: var(--text-primary);
transition: var(--transition);
cursor: pointer;
}
.btn-outline:hover {
border-color: var(--primary);
background: var(--primary-bg);
color: var(--primary);
}
/* ===== POST PAGE ===== */
.post-header {
margin-bottom: 2rem;
}
.post-title {
margin-bottom: 0.75rem;
}
.post-meta {
display: flex;
align-items: center;
gap: 1.5rem;
color: var(--text-muted);
font-size: 0.9rem;
margin-bottom: 1.5rem;
}
.post-meta span {
display: flex;
align-items: center;
gap: 0.4rem;
}
.post-image {
width: 100%;
border-radius: var(--radius-lg);
aspect-ratio: 16/9;
object-fit: cover;
margin-bottom: 2rem;
border: 1px solid var(--border);
}
.post-content {
color: var(--text-secondary);
line-height: 1.8;
font-size: 1rem;
margin-bottom: 3rem;
}
/* ===== COMMENT FORM ===== */
.comment-form-section {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 2rem;
margin-bottom: 2.5rem;
}
.comment-form-section h3 {
margin-bottom: 1.25rem;
font-size: 1.25rem;
}
.comment-form-section textarea {
background: var(--bg-input);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 0.75rem 1rem;
color: var(--text-primary);
font-size: 0.9rem;
font-family: 'Inter', sans-serif;
transition: var(--transition);
width: 100%;
min-height: 120px;
resize: vertical;
}
.comment-form-section textarea:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
outline: none;
}
.comment-form-section textarea::placeholder {
color: var(--text-muted);
}
/* ===== COMMENTS ===== */
.comments-section h3 {
margin-bottom: 1.5rem;
font-size: 1.25rem;
}
.comment {
display: flex;
gap: 1rem;
padding: 1.25rem 0;
border-bottom: 1px solid var(--border);
}
.comment:last-child {
border-bottom: none;
}
.comment-avatar {
width: 48px;
height: 48px;
min-width: 48px;
border-radius: 9999px;
background: var(--primary-bg);
color: var(--primary);
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: 1.1rem;
font-family: 'Raleway', sans-serif;
}
.comment-body {
flex: 1;
}
.comment-author {
font-weight: 600;
color: var(--text-primary);
font-size: 0.95rem;
margin-bottom: 0.25rem;
}
.comment-text {
color: var(--text-secondary);
font-size: 0.9rem;
line-height: 1.6;
}
/* Replies */
.replies {
margin-top: 1rem;
padding-left: 1.5rem;
border-left: 2px solid var(--border);
}
.reply {
display: flex;
gap: 0.75rem;
padding: 0.75rem 0;
}
.reply-avatar {
width: 36px;
height: 36px;
min-width: 36px;
border-radius: 9999px;
background: rgba(255, 255, 255, 0.05);
color: var(--text-muted);
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 0.85rem;
font-family: 'Raleway', sans-serif;
}
.reply .comment-author {
font-size: 0.9rem;
}
.reply .comment-text {
font-size: 0.85rem;
}
/* ===== ABOUT PAGE ===== */
.avatar {
max-width: 100%;
border-radius: 9999px;
border: 3px solid var(--border);
transition: var(--transition);
}
.avatar:hover {
border-color: var(--primary);
box-shadow: 0 0 40px rgba(230, 57, 70, 0.2);
}
/* ===== FOOTER ===== */
footer {
background: var(--bg-darker);
border-top: 1px solid var(--border);
padding: 2rem 0;
margin-top: 3rem;
}
.footer-content {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 1rem;
}
.footer-name {
color: var(--text-primary);
font-family: 'Raleway', sans-serif;
font-weight: 600;
font-size: 0.95rem;
}
.footer-group {
color: var(--text-muted);
font-size: 0.85rem;
}
.footer-links {
display: flex;
gap: 1.5rem;
}
.footer-links a {
color: var(--text-secondary);
font-size: 0.85rem;
transition: var(--transition);
}
.footer-links a:hover {
color: var(--primary);
transform: translateY(-2px);
}
/* ===== INDEX PAGE ===== */
.task-list li {
color: var(--text-secondary);
margin-bottom: 0.5rem;
}
.task-description {
color: var(--text-secondary);
}
.task-description .fw-bold,
p.fw-bold.task-description {
color: var(--text-primary);
}
.img-fluid.border {
border-color: var(--border) !important;
border-radius: var(--radius-md);
}
/* ===== DATA CARDS (Lab 2) ===== */
.data-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 2rem;
transition: var(--transition);
}
.data-card:hover {
border-color: var(--border-light);
}
.data-card h3 {
margin-bottom: 1.25rem;
font-size: 1.25rem;
}
.data-card h4 {
margin-bottom: 1rem;
font-size: 1.1rem;
}
/* ===== DATA TABLE ===== */
.data-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
border-radius: var(--radius-md);
overflow: hidden;
border: 1px solid var(--border);
}
.data-table thead th {
background: var(--bg-elevated);
color: var(--text-primary);
font-weight: 600;
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.5px;
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--border);
}
.data-table tbody td {
padding: 0.65rem 1rem;
font-size: 0.9rem;
color: var(--text-secondary);
border-bottom: 1px solid var(--border);
word-break: break-all;
}
.data-table tbody tr:last-child td {
border-bottom: none;
}
.data-table tbody tr:hover {
background: rgba(255, 255, 255, 0.02);
}
.data-table tbody td:first-child {
color: var(--primary);
font-weight: 500;
font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
font-size: 0.85rem;
}
.header-value {
max-width: 500px;
overflow: hidden;
text-overflow: ellipsis;
}
/* ===== FORMS (Lab 2) ===== */
.form-control {
background: var(--bg-input);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 0.75rem 1rem;
color: var(--text-primary);
font-size: 0.9rem;
transition: var(--transition);
}
.form-control:focus {
background: var(--bg-input);
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
outline: none;
color: var(--text-primary);
}
.form-control::placeholder {
color: var(--text-muted);
}
.form-control.is-invalid {
border-color: var(--error);
background: var(--bg-input);
}
.form-control.is-invalid:focus {
border-color: var(--error);
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.invalid-feedback {
color: var(--error);
font-size: 0.85rem;
margin-top: 0.5rem;
}
.form-label {
color: var(--text-primary);
font-weight: 500;
font-size: 0.9rem;
margin-bottom: 0.5rem;
}
/* ===== LOGIN FORM ===== */
.login-form {
margin-bottom: 1rem;
}
/* ===== PHONE RESULT ===== */
.result-card {
background: rgba(34, 197, 94, 0.1);
border: 1px solid rgba(34, 197, 94, 0.3);
border-radius: var(--radius-md);
padding: 1.25rem;
}
.result-card h4 {
color: var(--success);
margin-bottom: 0.5rem;
font-size: 1rem;
}
.formatted-phone {
color: var(--text-primary);
font-size: 1.5rem;
font-weight: 700;
font-family: 'Raleway', sans-serif;
letter-spacing: 0.05em;
}
/* ===== CODE BLOCK ===== */
.code-block {
background: var(--bg-darker);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 1.25rem;
}
.code-block code {
color: var(--primary-light);
font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
font-size: 0.9rem;
line-height: 1.8;
}
.text-muted-custom {
color: var(--text-muted);
font-size: 0.9rem;
font-style: italic;
}
.text-muted-custom code {
background: var(--bg-elevated);
padding: 0.2em 0.4em;
border-radius: 4px;
color: var(--primary-light);
font-size: 0.85rem;
}
/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
.post-meta {
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
}
.footer-content {
flex-direction: column;
text-align: center;
}
.comment {
gap: 0.75rem;
}
.comment-avatar {
width: 40px;
height: 40px;
min-width: 40px;
font-size: 0.95rem;
}
.replies {
padding-left: 1rem;
}
.data-card {
padding: 1.25rem;
}
.data-table tbody td,
.data-table thead th {
padding: 0.5rem 0.75rem;
font-size: 0.8rem;
}
.formatted-phone {
font-size: 1.25rem;
}
}

View file

@ -0,0 +1,19 @@
{% extends 'base.html' %}
{% block content %}
<h1 class="mt-5 text-center">Об авторе</h1>
<div class="row">
<div class="col-md-4 mb-3">
<img class="avatar" src="{{ url_for('static', filename='images/avatar.jpg') }}" alt="Author">
</div>
<div class="col-md-8 text-justify d-flex align-items-center">
<p>
Деев Егор Викторович — backend-разработчик и Python-специалист из Москвы, специализирующийся на создании backend-решений, парсинге данных, автоматизации процессов и интеграции AI-компонентов.
<br><br>
Обучается в Московском Политехническом университете (МосПолитех), владеет широким технологическим стеком, включающим Python (Django, FastAPI, Flask), работу с базами данных (PostgreSQL, SQLite), DevOps-инструменты (Docker, Nginx), а также frontend-технологии (HTML5, CSS3, JavaScript).
<br><br>
Контакты для связи: email egor@deev.space, Telegram @Egor_Deev, GitHub @EDeev, личный сайт deev.space с блогом и портфолио проектов.
</p>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,77 @@
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="https://deev.space/media/favicon.ico" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<title>
{% if title %}
{{ title }}
{% else %}
Лабораторная работа №2
{% endif %}
</title>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="container">
<a class="navbar-brand" href="{{ url_for('index') }}">Лабораторная работа № 2</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="{{ url_for('index') }}">Задание</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="{{ url_for('posts') }}">Посты</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('login') }}">Данные запроса</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('phone') }}">Телефон</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('about') }}">Об авторе</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<main class="my-1">
<div class="container">
{% block content %}
<h1>Содержимое по умолчанию</h1>
{% endblock %}
</div>
</main>
<footer>
<div class="container">
<div class="footer-content">
<div>
<div class="footer-name">Деев Егор Викторович, ст. гр. 241-327</div>
<div class="footer-group">Московский Политехнический университет</div>
</div>
<div class="footer-links">
<a href="mailto:egor@deev.space">egor@deev.space</a>
<a href="https://deev.space" target="_blank">My Site</a>
<a href="https://t.me/Egor_Deev" target="_blank">Telegram</a>
<a href="https://github.com/EDeev" target="_blank">GitHub</a>
</div>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>

View file

@ -0,0 +1,60 @@
{% extends 'base.html' %}
{% block content %}
<div class="row">
<div class="col-lg-12">
<h1 class="my-5">Задание к лабораторной работе №2</h1>
<p class="fw-bold task-description">
1. Отображение данных запроса.
</p>
<p class="task-description">Добавьте в приложение страницы, на которых отображаются:</p>
<ul class="my-3 task-list">
<li>параметры URL,</li>
<li>заголовки запроса,</li>
<li>cookie,</li>
<li>параметры формы.</li>
</ul>
<p class="task-description">
В качестве формы необходимо добавить форму авторизации. После того как в нее введены данные, эти данные выводятся на страницу.
</p>
<p class="fw-bold task-description mt-4">
2. Форма с обработкой ошибок.
</p>
<p class="task-description">
Создайте страницу с формой для ввода номера телефона. Форма должна состоять из текстового поля и кнопки «Проверить». По нажатию на кнопку данные формы должны отправляться на сервер при помощи метода POST.
</p>
<p class="task-description">На стороне сервера необходимо реализовать проверку, что в поле введён номер телефона заданного формата:</p>
<ul class="my-3 task-list">
<li>имеет длину 10-11 цифр;</li>
<li>может содержать дополнительные символы: пробелы, круглые скобки, дефисы, точки, +.</li>
</ul>
<p class="task-description">Если номер не соответствует формату выводить сообщение об ошибке:</p>
<ul class="my-3 task-list">
<li>«Недопустимый ввод. Неверное количество цифр.» если в номере не 10 или 11 цифр,</li>
<li>«Недопустимый ввод. В номере телефона встречаются недопустимые символы.» если в номере встречаются другие символы.</li>
</ul>
<p class="task-description">
Преобразовывать введённый номер к формату 8-***-***-**-** и выводить.
</p>
<p class="task-description">Примеры допустимых форматов ввода номера телефона:</p>
<div class="code-block my-3">
<code>+7 (123) 456-75-90</code><br>
<code>8(123)4567590</code><br>
<code>123.456.75.90</code>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,46 @@
{% extends 'base.html' %}
{% block content %}
<div class="row justify-content-center my-5">
<div class="col-lg-6">
<h1 class="mb-4">Проверка номера телефона</h1>
<div class="data-card">
<form method="POST" action="{{ url_for('phone') }}">
<div class="mb-3">
<label for="phone" class="form-label">Номер телефона</label>
<input
type="text"
class="form-control {% if error %}is-invalid{% endif %}"
id="phone"
name="phone"
placeholder="Например: +7 (123) 456-75-90"
value="{{ phone_value }}">
{% if error %}
<div class="invalid-feedback">
{{ error }}
</div>
{% endif %}
</div>
<button type="submit" class="btn btn-primary">Проверить</button>
</form>
{% if formatted_phone %}
<div class="result-card mt-4">
<h4>Результат</h4>
<p class="formatted-phone">{{ formatted_phone }}</p>
</div>
{% endif %}
</div>
<div class="data-card mt-4">
<h4>Допустимые форматы ввода</h4>
<div class="code-block">
<code>+7 (123) 456-75-90</code><br>
<code>8(123)4567590</code><br>
<code>123.456.75.90</code>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,56 @@
{% extends 'base.html' %}
{% block content %}
<div class="row justify-content-center my-5">
<div class="col-lg-10">
<div class="post-header">
<h1 class="post-title">{{ post.title }}</h1>
<div class="post-meta">
<span>{{ post.author }}</span>
<span>{{ post.date.strftime('%d.%m.%Y') }}</span>
</div>
</div>
<img class="post-image" src="{{ url_for('static', filename='images/' + post.image_id) }}" alt="{{ post.title }}">
<div class="post-content">
{{ post.text }}
</div>
<div class="comment-form-section">
<h3>Оставьте комментарий</h3>
<form method="POST">
<textarea name="comment" placeholder="Напишите ваш комментарий..." rows="4"></textarea>
<button type="submit" class="btn btn-primary mt-3">Отправить</button>
</form>
</div>
<div class="comments-section">
<h3>Комментарии ({{ post.comments | length }})</h3>
{% for comment in post.comments %}
<div class="comment">
<div class="comment-avatar">{{ comment.author[0] }}</div>
<div class="comment-body">
<div class="comment-author">{{ comment.author }}</div>
<div class="comment-text">{{ comment.text }}</div>
{% if comment.replies %}
<div class="replies">
{% for reply in comment.replies %}
<div class="reply">
<div class="reply-avatar">{{ reply.author[0] }}</div>
<div class="comment-body">
<div class="comment-author">{{ reply.author }}</div>
<div class="comment-text">{{ reply.text }}</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,25 @@
{% extends 'base.html' %}
{% block content %}
<h1 class="my-5">Последние посты</h1>
<div class="row mb-3">
{% for post in posts %}
<div class="col-md-6 d-flex">
<div class="card mb-4">
<img class="card-img-top" src="{{ url_for('static', filename='images/' + post.image_id) }}" alt="Card image cap">
<div class="card-body">
<h2 class="card-title">{{ post.title }}</h2>
<p class="card-text">
{{ post.text | truncate(100) }}
</p>
<a href="{{ url_for('post', index=loop.index0) }}" class="btn btn-primary">Читать дальше &rarr;</a>
</div>
<div class="card-footer text-muted">
Опубликовано {{ post.date.strftime('%d.%m.%Y') }}.
Автор: {{ post.author }}
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}

View file

@ -0,0 +1,116 @@
{% extends 'base.html' %}
{% block content %}
<div class="row justify-content-center my-5">
<div class="col-lg-10">
<h1 class="mb-4">Данные запроса</h1>
<div class="data-card mb-4">
<h3>Форма авторизации</h3>
<form method="POST" action="{{ url_for('login') }}" class="login-form">
<div class="mb-3">
<label for="login" class="form-label">Логин</label>
<input type="text" class="form-control" id="login" name="login" placeholder="Введите логин">
</div>
<div class="mb-3">
<label for="password" class="form-label">Пароль</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Введите пароль">
</div>
<button type="submit" class="btn btn-primary">Войти</button>
</form>
{% if form_data %}
<div class="mt-4">
<h4>Отправленные данные формы</h4>
<table class="data-table">
<thead>
<tr>
<th>Параметр</th>
<th>Значение</th>
</tr>
</thead>
<tbody>
<tr>
<td>login</td>
<td>{{ form_data.login }}</td>
</tr>
<tr>
<td>password</td>
<td>{{ form_data.password }}</td>
</tr>
</tbody>
</table>
</div>
{% endif %}
</div>
<div class="data-card mb-4">
<h3>Параметры URL (request.args)</h3>
{% if url_params %}
<table class="data-table">
<thead>
<tr>
<th>Параметр</th>
<th>Значение</th>
</tr>
</thead>
<tbody>
{% for key, value in url_params.items() %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted-custom">Нет параметров URL. Попробуйте добавить параметры в адресную строку, например: <code>?fname=Egor&lname=Deev&age=21</code></p>
{% endif %}
</div>
<div class="data-card mb-4">
<h3>Заголовки запроса (request.headers)</h3>
<table class="data-table">
<thead>
<tr>
<th>Заголовок</th>
<th>Значение</th>
</tr>
</thead>
<tbody>
{% for key, value in headers %}
<tr>
<td>{{ key }}</td>
<td class="header-value">{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="data-card mb-4">
<h3>Cookie (request.cookies)</h3>
{% if cookies %}
<table class="data-table">
<thead>
<tr>
<th>Имя</th>
<th>Значение</th>
</tr>
</thead>
<tbody>
{% for key, value in cookies.items() %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted-custom">Нет cookie в текущем запросе.</p>
{% endif %}
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,9 @@
click==8.0.4
Faker==13.3.2
Flask==2.0.3
itsdangerous==2.1.1
Jinja2==3.0.3
MarkupSafe==2.1.1
python-dateutil==2.8.2
six==1.16.0
Werkzeug==2.0.3