FINISHED
This commit is contained in:
parent
3c72bf8ca0
commit
bd797a5619
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="17" />
|
||||
<bytecodeTargetLevel target="18" />
|
||||
</component>
|
||||
</project>
|
2
gradle.properties
Normal file
2
gradle.properties
Normal file
@ -0,0 +1,2 @@
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
@ -14,25 +14,34 @@ public class Main {
|
||||
|
||||
port(8080);
|
||||
path("/backend", () -> {
|
||||
before("/*");
|
||||
before("/*", (request, response) -> response.header("Access-Control-Allow-Origin", "*"));
|
||||
|
||||
options("/*", (request, response) -> {
|
||||
String accessControlRequestHeaders = request.headers("Access-Control-Request-Headers");
|
||||
if (accessControlRequestHeaders != null) response.header("Access-Control-Allow-Headers", accessControlRequestHeaders);
|
||||
|
||||
String accessControlRequestMethod = request.headers("Access-Control-Request-Method");
|
||||
if (accessControlRequestMethod != null) response.header("Access-Control-Allow-Methods", accessControlRequestMethod);
|
||||
|
||||
return "OK";
|
||||
});
|
||||
|
||||
|
||||
get("/heartbeat", (req, res) -> {
|
||||
res.status(200);
|
||||
res.type("application/json");
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
return "{ \"up\":true }";
|
||||
});
|
||||
|
||||
get("/data/locations", (req, res) -> {
|
||||
res.status(200);
|
||||
res.type("application/json");
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
return new FileInputStream("locations.json");
|
||||
});
|
||||
|
||||
post("/generate", (req, res) -> {
|
||||
res.type("image/png");
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Expose-Headers", "Id");
|
||||
JsonObject data = new Gson().fromJson(req.body(), JsonObject.class);
|
||||
return new VCard(data).toByteArray();
|
||||
});
|
||||
@ -41,7 +50,6 @@ public class Main {
|
||||
req.attribute("org.eclipse.jetty.multipartConfig", new MultipartConfigElement("/temp"));
|
||||
res.status(200);
|
||||
res.type("application/json");
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
return VCard.getDataFromVCard(req.raw().getPart("card").getInputStream());
|
||||
});
|
||||
});
|
||||
|
@ -2,21 +2,14 @@ package tech.nevets.vcardgen;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import spark.Request;
|
||||
import spark.Response;
|
||||
import spark.Route;
|
||||
|
||||
import javax.imageio.*;
|
||||
import javax.imageio.metadata.IIOMetadata;
|
||||
import javax.imageio.metadata.IIOMetadataNode;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user