-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
alina tarasova
committed
Feb 19, 2024
1 parent
e340c07
commit 9b3336a
Showing
1 changed file
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |