Make port configurable

This commit is contained in:
2024-08-07 15:30:28 -04:00
parent decc0598b1
commit cf11c6bc1d
4 changed files with 30 additions and 23 deletions

View File

@@ -14,7 +14,12 @@ import static spark.Spark.*;
public class Server {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public static void main(String[] args) {
port(8080);
if (args.length >= 1) {
port(Integer.parseInt(args[0]));
} else {
port(8080);
}
post("/ngx/create", (req, res) -> {
JsonObject jsonObject = GSON.fromJson(req.body(), JsonObject.class);
TextStorage ts = TextStorage.createPaste(jsonObject.get("content").getAsString());