forked from Steven/NginxInstallerBackend
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
3213751418 | |||
e2b1394ea2 | |||
cf11c6bc1d | |||
|
a954dc49f4 | ||
decc0598b1 |
@ -6,10 +6,14 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="ceecbd3e-6a84-488d-ae73-a0b5b3f4010e" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
|
||||
<<<<<<< HEAD
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
=======
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/tech/nevets/ngxinstaller/Server.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/tech/nevets/ngxinstaller/Server.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/tech/nevets/ngxinstaller/TextStorage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/tech/nevets/ngxinstaller/TextStorage.java" afterDir="false" />
|
||||
>>>>>>> a954dc49f4c6943f06c97c50957ac1b1ac48088b
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -60,6 +64,25 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<<<<<<< HEAD
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Gradle.NginxInstallerBackend [:Server.main()].executor": "Debug",
|
||||
"Gradle.NginxInstallerBackend [shadowJar].executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}</component>
|
||||
<component name="RunManager" selected="Gradle.NginxInstallerBackend [shadowJar]">
|
||||
=======
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Gradle.NginxInstallerBackend [:Server.main()].executor": "Debug",
|
||||
@ -80,6 +103,7 @@
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="Application.Server">
|
||||
>>>>>>> a954dc49f4c6943f06c97c50957ac1b1ac48088b
|
||||
<configuration name="Server" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="tech.nevets.ngxinstaller.Server" />
|
||||
<module name="NginxInstallerBackend.main" />
|
||||
@ -137,8 +161,14 @@
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1703015833777</updated>
|
||||
<<<<<<< HEAD
|
||||
<workItem from="1703015834937" duration="11923000" />
|
||||
<workItem from="1703098848808" duration="606000" />
|
||||
<workItem from="1704314407897" duration="15000" />
|
||||
=======
|
||||
<workItem from="1703015834937" duration="5516000" />
|
||||
<workItem from="1703185574324" duration="1576000" />
|
||||
>>>>>>> a954dc49f4c6943f06c97c50957ac1b1ac48088b
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'tech.nevets'
|
||||
version = '0.1.0'
|
||||
version = '0.1.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
@ -18,12 +19,17 @@ public class Server {
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
public static String cachedNginxSite = "";
|
||||
public static void main(String[] args) {
|
||||
if (args.length >= 1) {
|
||||
port(Integer.parseInt(args[0]));
|
||||
} else {
|
||||
port(8080);
|
||||
}
|
||||
|
||||
try {
|
||||
cachedNginxSite = getHTML("https://nginx.org/download/");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
port(8080);
|
||||
options("/*",
|
||||
(request, response) -> {
|
||||
|
||||
@ -70,6 +76,21 @@ public class Server {
|
||||
get("/ngx/raw/*", (req, res) -> {
|
||||
String id = req.splat()[0];
|
||||
TextStorage ts = TextStorage.getPaste(id);
|
||||
res.type("text/plain");
|
||||
if (ts == null) {
|
||||
res.status(404);
|
||||
return "Content Not Found!";
|
||||
}
|
||||
return URLDecoder.decode(ts.getText(), StandardCharsets.UTF_8);
|
||||
});
|
||||
get("/ngx/json/*", (req, res) -> {
|
||||
String id = req.splat()[0];
|
||||
TextStorage ts = TextStorage.getPaste(id);
|
||||
res.type("application/json");
|
||||
if (ts == null) {
|
||||
res.status(404);
|
||||
return "{\"error\":\"content not found\"}";
|
||||
}
|
||||
res.type("raw");
|
||||
return ts.getText();
|
||||
});
|
||||
|
@ -19,14 +19,14 @@ public class TextStorage {
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public static TextStorage getPaste(String id) {
|
||||
for (TextStorage ts : DB) {
|
||||
if (ts.id.equals(id)) {
|
||||
@ -37,7 +37,7 @@ public class TextStorage {
|
||||
}
|
||||
|
||||
public static TextStorage createPaste(String text) {
|
||||
TextStorage ts = new TextStorage(generateId(), text, System.currentTimeMillis() + 3600000);
|
||||
TextStorage ts = new TextStorage(generateId(), text, System.currentTimeMillis() + 1800000);
|
||||
DB.add(ts);
|
||||
return ts;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user