Skip to content

Commit cbbd0eb

Browse files
authored
Fix rendering of job results in html (#1870)
* Fix rendering of job results in html This is basically the same fix as 42f8334 , but in a different template. * Use pygeoapi.util.to_json instead of jinja tojson
1 parent e27318f commit cbbd0eb

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

pygeoapi/templates/jobs/job.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h3>{% trans %}Parameters{% endtrans %}</h3>
2727
<pre id="job-parameters"></pre>
2828
</div>
2929
<script>
30-
var parameters = {{ data['jobs']['parameters'] | tojson }};
30+
var parameters = {{ data['jobs']['parameters'] | to_json | safe }};
3131
document.getElementById('job-parameters').innerHTML = JSON.stringify(JSON.parse(parameters), undefined, 2);
3232
</script>
3333
{% endif %}

pygeoapi/templates/jobs/results/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ <h2>{% trans %}Results of job{% endtrans %} {{data.job.id}}</h2>
1111
<pre id="results"></pre>
1212
</section>
1313
<script>
14-
document.getElementById('results').innerHTML = JSON.stringify({{ data.result }}, undefined, 2);
14+
document.getElementById('results').innerHTML = JSON.stringify({{ data.result | to_json | safe }}, undefined, 2);
1515
</script>
1616
{% endblock %}

tests/api/test_processes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ def test_get_job_result(api_):
435435
# default response is html
436436
assert code == HTTPStatus.OK
437437
assert rsp_headers['Content-Type'] == 'text/html'
438-
assert 'Hello Sync Test!' in response
438+
result = 'JSON.stringify({"id":"echo","value":"Hello Sync Test!"}'
439+
assert result in response
439440

440441
rsp_headers, code, response = get_job_result(
441442
api_, mock_api_request({'f': 'json'}), job_id,

0 commit comments

Comments
 (0)