Skip to content

6411 Подтягина А.Ю. Лаб.2 Вар.2#112

Open
nastya1302 wants to merge 3 commits intoitsecd:mainfrom
nastya1302:main
Open

6411 Подтягина А.Ю. Лаб.2 Вар.2#112
nastya1302 wants to merge 3 commits intoitsecd:mainfrom
nastya1302:main

Conversation

@nastya1302
Copy link
Copy Markdown

@nastya1302 nastya1302 commented Apr 6, 2026

Веб-приложение для просмотра расписания пригородных поездов с использованием API Яндекс.Расписаний.

Backend: Flask, yaschedule, requests
Frontend: HTML5, CSS3, jQuery, Яндекс.Карты API
API: Яндекс.Расписания

Как запустить проект:

  1. cd electric-train-tracker
  2. Установить зависимости
    cd backend
    pip install -r requirements.txt
  3. Запустить сервер
    python server.py
  4. Открыть в браузере
    http://localhost:5000

@AvtoBBus AvtoBBus self-requested a review April 9, 2026 11:58
CORS(app)

API_KEY = os.getenv('YANDEX_API_KEY')
FLASK_DEBUG = os.getenv('FLASK_DEBUG', 'True') == 'True'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== 'True'

явно лишнее

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это можно в .gitignore

Comment on lines +91 to +98
popular_stations = [
{'name': 'Москва (Киевский вокзал)', 'code': 's9603402'},
{'name': 'Санкт-Петербург (Витебский)', 'code': 's9603551'},
{'name': 'Москва (Казанский вокзал)', 'code': 's9603404'},
{'name': 'Москва (Ярославский вокзал)', 'code': 's9603408'},
{'name': 'Москва (Павелецкий вокзал)', 'code': 's9603405'},
]
return jsonify(popular_stations)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом нормально, так как написание алгоритма отбора популярных остановок явно сильно выходит за рамки лабы

Copy link
Copy Markdown
Collaborator

@AvtoBBus AvtoBBus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Немного поправить

Comment on lines +276 to +281
ymaps.ready(() => {
map = new ymaps.Map('map', {
center: [55.751574, 37.573856],
zoom: 10,
controls: ['zoomControl', 'fullscreenControl', 'geolocationControl']
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Карта не загружается

Image

Потому что строкой выше вы проверяете на undefined переменную, которую ранее не объявили нигде

Comment on lines +336 to +353
hintContent: stationName,
balloonContent: `<div class="station-balloon"><strong>${stationName}</strong><br><small>Расстояние: ${distance} км</small><br><button id="${buttonId}" style="margin-top:8px; background:#1a1a2e; color:white; border:none; padding:5px 10px; border-radius:6px; cursor:pointer;">Выбрать станцию</button></div>`
}, { preset: 'islands#blueRailwayIcon' });

marker.events.add('balloonopen', function() {
const button = document.getElementById(buttonId);
if (button) button.onclick = () => { selectStationFromMap(stationCode, stationName); marker.balloon.close(); };
});

map.geoObjects.add(marker);
mapMarkers.push(marker);
}

const stationItem = $(`<div class="nearby-station-item" data-code="${stationCode}" data-name="${stationName}"><i class="fas fa-train"></i><div class="station-info"><strong>${stationName}</strong><span class="distance">${distance} км</span>${city ? `<span class="city">${city}</span>` : ''}</div><button class="select-station-btn">Выбрать</button></div>`);
stationItem.find('.select-station-btn').click(() => selectStationFromMap(stationCode, stationName));
stationItem.click(() => selectStationFromMap(stationCode, stationName));
$('#nearby-stations-list').append(stationItem);
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Во-первых, мне больно глаза, не нужно html в одну строку;
Во-вторых, здесь и в остальных местах, где идёт генерация верстки, вынесите в отдельный файл

Comment on lines +206 to +221
function toggleFavorite(name) {
const idx = favorites.indexOf(name);
if (idx === -1) {
favorites.push(name);
showMessage(`❤️ ${name} добавлена в избранное`);
} else {
favorites.splice(idx, 1);
showMessage(`💔 ${name} удалена из избранного`);
}
localStorage.setItem('railway_favorites', JSON.stringify(favorites));
renderFavorites();
}

function isFavorite(name) {
return favorites.includes(name);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Везде где идёт взаимодействие и работа с любимыми остановками и localStorage, во-первых проверяйте, что он доступен, а во-вторых, вынесите функции в отдельный файл

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants