Skip to content

Commit

Permalink
Added App.java
Browse files Browse the repository at this point in the history
  • Loading branch information
alina tarasova committed Feb 19, 2024
1 parent e340c07 commit 9b3336a
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions app/src/main/java/hexlet/code/App.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
package hexlet.code;

public class Main {
import io.javalin.Javalin;

public class App {

private static int getPort() {
String port = System.getenv().getOrDefault("PORT", "7070");
return Integer.valueOf(port);
}

// private static String readResourceFile(String fileName) throws IOException {
// var inputStream = HelloWorld.class.getClassLoader().getResourceAsStream(fileName);
// try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
// return reader.lines().collect(Collectors.joining("\n"));
// }
// }

public static Javalin getApp() {
var app = Javalin.create(config -> {
config.plugins.enableDevLogging();
});

app.get("/", ctx -> {
ctx.result("Hello World");
});

return app;
}

public static void main(String[] args) {
System.out.println("Hello world!");
Javalin app = getApp();
app.start(getPort());
}
}

0 comments on commit 9b3336a

Please sign in to comment.