Files
KittyBot/src/network/NetworkColiru.java
T
Alex Stewart 13420951b1 Initial Commit
Initial commit of project.
2019-03-09 01:21:44 -08:00

30 lines
811 B
Java

package network;
import utils.HTTPUtils;
public class NetworkColiru
{
public String compileCPlus(String query)
{
// Escape characters that need escaping.
// Primarily types of whitespace.
query = query.replace("\\n", "\\\\n");
query = query.replace("\\t", "\\\\t");
query = query.replace("\n", "\\n");
query = query.replace("\"", "\\\"");
query = query.replace("\t", "\\t");
// Send the compilation request!
String result = HTTPUtils.SendPOSTRequest("http://coliru.stacked-crooked.com/compile"
, "{ \"cmd\": \"g++ main.cpp && ./a.out\", \"src\": \"" + query + "\" }");
// If we got a valid response...
if(!result.isEmpty())
{
result = "Here's what happened when I went to compiled that! \n```" + result + "```";
}
return result;
}
}