Compare commits
8 Commits
web-server
...
master
Author | SHA1 | Date | |
---|---|---|---|
47508c765c | |||
6951f4ad56 | |||
8314a770f1 | |||
638eb97390 | |||
39caa53de6 | |||
7c242da452 | |||
|
e7050f2e42 | ||
bf333dd686 |
@ -11,8 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static spark.Spark.get;
|
||||
import static spark.Spark.port;
|
||||
import static spark.Spark.*;
|
||||
|
||||
public class App {
|
||||
|
||||
@ -21,9 +20,34 @@ public class App {
|
||||
get("/search", (req, res) -> {
|
||||
Gson gson = new Gson();
|
||||
String[] words = req.queryParams("s").split("/+");
|
||||
System.out.println("Request : " + req.queryParams("s"));
|
||||
ArrayList<Result> results = getResults(words);
|
||||
return gson.toJson(results);
|
||||
String json = gson.toJson(results);
|
||||
|
||||
System.out.println(json);
|
||||
return json;
|
||||
});
|
||||
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";
|
||||
});
|
||||
|
||||
before((request, response) -> response.header("Access-Control-Allow-Origin", "*"));
|
||||
}
|
||||
|
||||
private static ArrayList<Result> getResults(String[] words) throws Exception {
|
||||
|
@ -6,9 +6,6 @@ RUN apt-get update; apt-get install -y git wget;
|
||||
|
||||
RUN cd /root; wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz; wget http://mirror.navercorp.com/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
|
||||
|
||||
RUN echo "export JAVA_HOME=/root/jdk-11" \
|
||||
echo "export PATH=$PATH:/root/jdk-11/bin:/root/apache-maven-3.6.1/bin"
|
||||
|
||||
RUN cd /root; tar -xsvf openjdk-11+28_linux-x64_bin.tar.gz; tar -xsvf apache-maven-3.6.1-bin.tar.gz
|
||||
|
||||
EXPOSE 8080
|
||||
|
6
docker/start.sh
Normal file → Executable file
6
docker/start.sh
Normal file → Executable file
@ -1,6 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm -rdf
|
||||
rm -rdf /root/nlp
|
||||
|
||||
export JAVA_HOME=/root/jdk-11
|
||||
export PATH=$PATH:/root/jdk-11/bin:/root/apache-maven-3.6.1/bin
|
||||
|
||||
git clone https://git.sanchezm.fr/mathieu/CAU-NLP-Spring-2019-PQ-Man-Server.git /root/nlp
|
||||
cd /root/nlp/CAu_NLP_2019
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user