From 9a20a232651dd13bd1496594413454d49465099c Mon Sep 17 00:00:00 2001 From: Rsclub2 2 Date: Wed, 18 Oct 2023 14:57:37 +0200 Subject: [PATCH] Update for cancelled and also for from --- Hafas_Main_web_old.py | 41 ------------------- templates/index.html | 93 +++++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 84 deletions(-) delete mode 100644 Hafas_Main_web_old.py diff --git a/Hafas_Main_web_old.py b/Hafas_Main_web_old.py deleted file mode 100644 index 4594ffe..0000000 --- a/Hafas_Main_web_old.py +++ /dev/null @@ -1,41 +0,0 @@ -import datetime -from typing import List -from flask import Flask, render_template, request, make_response -import json -import requests - -app = Flask(__name__) - -def get_departure_info(station_name): - url = f"https://dbf.finalrewind.org/{station_name}.json?version=3" - response = requests.get(url) - if response.status_code == 200: - departures_data = response.json().get("departures", []) - departures = [station_board_leg_to_dict(leg) for leg in departures_data] - return departures - else: - return [] - -def station_board_leg_to_dict(leg): - return { - "name": leg["train"], - "direction": leg["destination"], - "dateTime": leg["scheduledDeparture"], - "delay": leg["delayDeparture"], - "platform": leg["scheduledPlatform"], - } - -@app.route('/', methods=['GET', 'POST']) -def index(): - departures = [] - station_name = "" - - # Get the station name from the form input - if request.method == 'POST': - station_name = request.form['station_name'] - departures = get_departure_info(station_name) - - return render_template('index.html', departures=departures, station_name=station_name) - -if __name__ == '__main__': - app.run(host="0.0.0.0", debug=False) diff --git a/templates/index.html b/templates/index.html index c1916d9..2d53c2d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -103,6 +103,9 @@ color: #FF5000; font-weight: bold; } + .cancelled-row { + background-color: #500303; + }