Skip to content
Snippets Groups Projects
Verified Commit 645e267d authored by Owen Graham's avatar Owen Graham
Browse files

Stop fetching source links, use redirects instead

parent 15412d46
Branches
No related tags found
No related merge requests found
from flask import abort, Flask, g, jsonify, render_template
from flask import abort, Flask, g, jsonify, redirect, render_template
from .parameters import get_param, year_type
from .plotting import plotters
......@@ -47,12 +47,12 @@ def render_plotter(name, embedded):
plot_view=f'plot-views/{view_name}.html')
@app.route('/record/link')
def record_link():
"""Return the source link for the selected dataset."""
@app.route('/source')
def source_redirect():
"""Redirect to the selected dataset."""
station = get_station(get_param('station'))
year = get_param('year', to=year_type)
return jsonify(get_link(station, year))
return redirect(get_link(station, year), code=307) # Temporary Redirect
@app.route('/plot/<name>.png')
......
......@@ -101,13 +101,9 @@ function sourceLink(station, year, n) {
if (EMBEDDED) {
a.target = '_blank';
}
div.appendChild(a);
const params = new URLSearchParams({station, year});
fetch(`${SCRIPT_ROOT}/record/link?${params}`)
.then(response => response.json())
.then(response => {
a.href = response;
});
a.href = `${SCRIPT_ROOT}/source?${params}`;
div.appendChild(a);
return div;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment