Make ports configurable
This commit is contained in:
parent
6bf31736e3
commit
fe6f88bc62
@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleHome" value="C:/Program Files/Gradle" />
|
<option name="gradleHome" value="$PROJECT_DIR$/../../../../Program Files/Gradle" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
|
@ -4,16 +4,14 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'tech.nevets'
|
group 'tech.nevets'
|
||||||
version '1.0'
|
version '1.1.0'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'io.javalin:javalin:4.6.0'
|
implementation 'com.sparkjava:spark-core:2.9.4'
|
||||||
implementation 'org.slf4j:slf4j-simple:1.7.36'
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
@ -1,44 +1,27 @@
|
|||||||
package tech.nevets.beerestapi;
|
package tech.nevets.beerestapi;
|
||||||
|
|
||||||
import io.javalin.Javalin;
|
import java.util.List;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
import static spark.Spark.*;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static ArrayList<String> urls = new ArrayList<>();
|
public static List<String> urls = List.of(
|
||||||
|
"vetlog.jpg",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
getImageUrlList();
|
if (args[0] != null) {
|
||||||
Javalin app = Javalin.create().start(8080);
|
port(Integer.parseInt(args[0]));
|
||||||
|
} else {
|
||||||
app.get("/bee", ctx -> {
|
port(8080);
|
||||||
ctx.json("{\"link\": \"https://img.nevets.tech/" + getRandomUrl() + "\"}");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void getImageUrlList() {
|
|
||||||
String line;
|
|
||||||
BufferedReader in = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
in = new BufferedReader(new FileReader("./image-urls.txt"));
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
urls.add(line);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get("/bee", (req, res) -> {
|
||||||
|
return "{\"link\": \"https://img.nevets.tech/" + getRandomUrl() + "\"}";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRandomUrl() {
|
public static String getRandomUrl() {
|
||||||
|
Loading…
Reference in New Issue
Block a user