Skip to content

Commit

Permalink
Fix rendering of job results in html (#1870)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
totycro authored Dec 11, 2024
1 parent e27318f commit cbbd0eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pygeoapi/templates/jobs/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h3>{% trans %}Parameters{% endtrans %}</h3>
<pre id="job-parameters"></pre>
</div>
<script>
var parameters = {{ data['jobs']['parameters'] | tojson }};
var parameters = {{ data['jobs']['parameters'] | to_json | safe }};
document.getElementById('job-parameters').innerHTML = JSON.stringify(JSON.parse(parameters), undefined, 2);
</script>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/templates/jobs/results/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ <h2>{% trans %}Results of job{% endtrans %} {{data.job.id}}</h2>
<pre id="results"></pre>
</section>
<script>
document.getElementById('results').innerHTML = JSON.stringify({{ data.result }}, undefined, 2);
document.getElementById('results').innerHTML = JSON.stringify({{ data.result | to_json | safe }}, undefined, 2);
</script>
{% endblock %}
3 changes: 2 additions & 1 deletion tests/api/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ def test_get_job_result(api_):
# default response is html
assert code == HTTPStatus.OK
assert rsp_headers['Content-Type'] == 'text/html'
assert 'Hello Sync Test!' in response
result = 'JSON.stringify({"id":"echo","value":"Hello Sync Test!"}'
assert result in response

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

0 comments on commit cbbd0eb

Please sign in to comment.