diff -r 18953691af29 -r 428cfdf64ccc service.py --- a/service.py Mon Jul 31 01:15:28 2017 +0300 +++ b/service.py Fri Aug 11 14:28:13 2017 +0300 @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from flask import Flask, render_template, abort, send_from_directory +from flask import Flask, render_template, abort, send_from_directory, redirect from datetime import datetime, date, time, timedelta from os import path, listdir from configparser import ConfigParser @@ -77,7 +77,7 @@ def imminent(schedule_entry): return (schedule_entry['time'] - now()) <= timedelta(minutes = 3) -@app.route('/pysäkki/') +@app.route('/stop/') def bus_stop_schedule(reference): from buses import bus_stops schedule = [] @@ -120,7 +120,7 @@ with activate_locale(): return time.strftime('%-d.%-m. %H:%M').replace(' ', '\xa0') -@app.route('/pysäkkiryhmä/') +@app.route('/stop_cluster/') def cluster_schedule(cluster_name): from buses import bus_stops, clusters_by_name schedule = [] @@ -159,7 +159,7 @@ tr = tr, ) -@app.route('/ajovuoro/') +@app.route('/trip/') def trip(trip_reference): from flask import request from buses import all_trips @@ -205,7 +205,7 @@ length = trip.length / 1000, ) -@app.route('/linja/') +@app.route('/route/') def route_page(name): from buses import routes route = routes[name.upper()] @@ -224,6 +224,22 @@ schedule = schedule, ) +@app.route('/') +def index(): + return redirect('/stop_cluster/kauppatori') + +@app.route('/pysäkki/') +def redirect_pysäkki(reference): + return redirect('/stop/' + str(reference)) + +@app.route('/pysäkkiryhmä/') +def redirect_pysäkkiryhmä(reference): + return redirect('/stop_cluster/' + str(reference)) + +@app.route('/ajovuoro/') +def redirect_ajovuoro(reference): + return redirect('/trip/' + str(reference)) + @app.route('/static/') def static_file(path): return send_from_directory(path.join('static', path))