(feat) make the "Command exited with code X" red if the code is not 0
This commit is contained in:
parent
2521075aef
commit
b390f74431
|
@ -39,13 +39,20 @@ async fn executor(_state: SharedState, data: ExecutorData) -> Result<Box<dyn Rep
|
|||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
let exit_status = out.wait().unwrap();
|
||||
let exit_status = out.wait().unwrap().code().unwrap();
|
||||
|
||||
let mut buf = vec![];
|
||||
out.stdout.unwrap().read_to_end(&mut buf).unwrap();
|
||||
|
||||
let mut stdout = String::from_utf8(buf).unwrap();
|
||||
stdout += format!("\n---\nCommand exited with code {}", exit_status.code().unwrap()).as_str();
|
||||
stdout += "\n---\n";
|
||||
if exit_status != 0 {
|
||||
stdout += format!("<span style='color:red;font-weight:bolder'>Command exited with code {}</span>", exit_status).as_str();
|
||||
} else {
|
||||
stdout += "Command exited with code 0";
|
||||
}
|
||||
|
||||
let stdout = stdout.replace('\n', "<br>");
|
||||
|
||||
Ok(Box::new(warp::reply::json(&stdout)))
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@ async function executeCode(code, lang) {
|
|||
}
|
||||
)
|
||||
const out = await data.json();
|
||||
document.getElementById('output').value = out;
|
||||
document.getElementById('output').innerHTML = out;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</button>
|
||||
</div>
|
||||
<div id='container'></div>
|
||||
<textarea id="output" readonly></textarea>
|
||||
<pre id="output" readonly></pre>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
|
|
Loading…
Reference in New Issue