Various improvements
This commit is contained in:
parent
a8e0bd39e5
commit
2090268754
3 changed files with 13 additions and 12 deletions
9
app.py
9
app.py
|
|
@ -33,6 +33,15 @@ def index():
|
||||||
return render_template('index.html', destinations=DESTINATIONS, today=today)
|
return render_template('index.html', destinations=DESTINATIONS, today=today)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/search')
|
||||||
|
def search():
|
||||||
|
slug = request.args.get('destination', '')
|
||||||
|
travel_date = request.args.get('travel_date', '')
|
||||||
|
if slug in DESTINATIONS and travel_date:
|
||||||
|
return redirect(url_for('results', slug=slug, travel_date=travel_date))
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/results/<slug>/<travel_date>')
|
@app.route('/results/<slug>/<travel_date>')
|
||||||
def results(slug, travel_date):
|
def results(slug, travel_date):
|
||||||
destination = DESTINATIONS.get(slug)
|
destination = DESTINATIONS.get(slug)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 style="margin-top:0">Plan your journey</h2>
|
<h2 style="margin-top:0">Plan your journey</h2>
|
||||||
<form id="journey-form">
|
<form method="get" action="{{ url_for('search') }}">
|
||||||
<div style="margin-bottom:1.2rem">
|
<div style="margin-bottom:1.2rem">
|
||||||
<label for="destination" style="display:block;font-weight:600;margin-bottom:0.4rem">
|
<label for="destination" style="display:block;font-weight:600;margin-bottom:0.4rem">
|
||||||
Eurostar destination
|
Eurostar destination
|
||||||
|
|
@ -32,12 +32,4 @@
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
|
||||||
document.getElementById('journey-form').addEventListener('submit', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
const slug = this.querySelector('[name="destination"]').value;
|
|
||||||
const date = this.querySelector('[name="travel_date"]').value;
|
|
||||||
if (slug && date) window.location.href = '/results/' + slug + '/' + date;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<p style="margin-bottom:1rem">
|
<p style="margin-bottom:1rem">
|
||||||
<a href="/">← New search</a>
|
<a href="{{ url_for('index') }}">← New search</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="card" style="margin-bottom:1.5rem">
|
<div class="card" style="margin-bottom:1.5rem">
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
Bristol Temple Meads → {{ destination }}
|
Bristol Temple Meads → {{ destination }}
|
||||||
</h2>
|
</h2>
|
||||||
<div style="display:flex;align-items:center;gap:0.75rem;margin-bottom:0.5rem">
|
<div style="display:flex;align-items:center;gap:0.75rem;margin-bottom:0.5rem">
|
||||||
<a href="/results/{{ slug }}/{{ prev_date }}"
|
<a href="{{ url_for('results', slug=slug, travel_date=prev_date) }}"
|
||||||
style="padding:0.3rem 0.75rem;border:1px solid #cbd5e0;border-radius:4px;
|
style="padding:0.3rem 0.75rem;border:1px solid #cbd5e0;border-radius:4px;
|
||||||
text-decoration:none;color:#00539f;font-size:0.9rem">← Prev</a>
|
text-decoration:none;color:#00539f;font-size:0.9rem">← Prev</a>
|
||||||
<strong>{{ travel_date_display }}</strong>
|
<strong>{{ travel_date_display }}</strong>
|
||||||
<a href="/results/{{ slug }}/{{ next_date }}"
|
<a href="{{ url_for('results', slug=slug, travel_date=next_date) }}"
|
||||||
style="padding:0.3rem 0.75rem;border:1px solid #cbd5e0;border-radius:4px;
|
style="padding:0.3rem 0.75rem;border:1px solid #cbd5e0;border-radius:4px;
|
||||||
text-decoration:none;color:#00539f;font-size:0.9rem">Next →</a>
|
text-decoration:none;color:#00539f;font-size:0.9rem">Next →</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue