From b390f74431bcd4f4a6bad0d3c75641d6f2db3533 Mon Sep 17 00:00:00 2001 From: b1ek Date: Sun, 18 Feb 2024 01:00:01 +1000 Subject: [PATCH] (feat) make the "Command exited with code X" red if the code is not 0 --- src/web/executor.rs | 11 +++++++++-- static/script/executor.js | 2 +- templates/index.html | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/web/executor.rs b/src/web/executor.rs index 99e0066..646bb7e 100644 --- a/src/web/executor.rs +++ b/src/web/executor.rs @@ -39,13 +39,20 @@ async fn executor(_state: SharedState, data: ExecutorData) -> ResultCommand exited with code {}", exit_status).as_str(); + } else { + stdout += "Command exited with code 0"; + } + + let stdout = stdout.replace('\n', "
"); Ok(Box::new(warp::reply::json(&stdout))) } diff --git a/static/script/executor.js b/static/script/executor.js index 9211398..a905763 100644 --- a/static/script/executor.js +++ b/static/script/executor.js @@ -13,5 +13,5 @@ async function executeCode(code, lang) { } ) const out = await data.json(); - document.getElementById('output').value = out; + document.getElementById('output').innerHTML = out; } diff --git a/templates/index.html b/templates/index.html index 83346fa..108952e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -34,7 +34,7 @@
- +

 {% endblock %}
 
 {% block script %}