Handle location data on backend from id

This commit is contained in:
Steven Tracey 2023-04-27 13:51:28 -04:00
parent 728092dfed
commit 9fdff1ecba
4 changed files with 24 additions and 27 deletions

View File

@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="temurin-18" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="temurin-18" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

20
locations.json Normal file
View File

@ -0,0 +1,20 @@
[
{
"id": "caiu",
"name": "Capital Area Intermediate Unit",
"address": "55 Miller St, Enola, PA, 17025",
"phone": "(717)732-8400"
},
{
"id": "caelc",
"name": "Capital Area Early Learning Center",
"address": "4100 Gettysburg Rd, Camp Hill, PA, 17011",
"phone": "(717)732-"
},
{
"id": "hta",
"name": "Hill Top Academy",
"address": "405 E Winding Hill Rd, Mechanicsburg, PA, 17055",
"phone": "(717)732-8484"
}
]

View File

@ -7,6 +7,7 @@ import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import static spark.Spark.*;
@ -38,11 +39,12 @@ public class Main {
res.status(200);
res.type("application/json");
res.header("Access-Control-Allow-Origin", "*");
return Main.class.getResourceAsStream("/locations.json");
return new FileInputStream("locations.json");
});
post("/", (req, res) -> {
res.type("image/png");
res.header("Access-Control-Allow-Origin", "*");
JsonObject data = new Gson().fromJson(req.body(), JsonObject.class);
return generate(
data.get("name").getAsString(),

View File

@ -1,25 +0,0 @@
{
"locations": [
{
"caiu": {
"name": "Capital Area Intermediate Unit",
"address": "55 Miller St, Enola, PA, 17025",
"phone": "(717)732-8400"
}
},
{
"caelc": {
"name": "Capital Area Early Learning Center",
"address": "4100 Gettysburg Rd, Camp Hill, PA, 17011",
"phone": "(717)732-"
}
},
{
"hta": {
"name": "Hill Top Academy",
"address": "405 E Winding Hill Rd, Mechanicsburg, PA, 17055",
"phone": "(717)732-8484"
}
}
]
}