Compare commits

..

8 Commits

Author SHA1 Message Date
47508c765c Print final result 2019-06-12 22:09:35 +09:00
6951f4ad56 Add log request 2019-06-12 21:31:38 +09:00
8314a770f1 Add CORS 2019-06-12 17:33:54 +09:00
638eb97390 Export in bashrc 2019-06-12 14:19:35 +09:00
39caa53de6 Export in bashrc 2019-06-12 14:15:02 +09:00
7c242da452 Export in bashrc 2019-06-12 14:09:26 +09:00
root
e7050f2e42 Chmod 777 start 2019-06-12 05:01:07 +00:00
bf333dd686 Change start.sh 2019-06-12 14:00:16 +09:00
3 changed files with 32 additions and 7 deletions

View File

@ -11,8 +11,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static spark.Spark.get; import static spark.Spark.*;
import static spark.Spark.port;
public class App { public class App {
@ -21,9 +20,34 @@ public class App {
get("/search", (req, res) -> { get("/search", (req, res) -> {
Gson gson = new Gson(); Gson gson = new Gson();
String[] words = req.queryParams("s").split("/+"); String[] words = req.queryParams("s").split("/+");
System.out.println("Request : " + req.queryParams("s"));
ArrayList<Result> results = getResults(words); 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 { private static ArrayList<Result> getResults(String[] words) throws Exception {

View File

@ -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 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 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 EXPOSE 8080

6
docker/start.sh Normal file → Executable file
View File

@ -1,6 +1,10 @@
#!/bin/bash #!/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 git clone https://git.sanchezm.fr/mathieu/CAU-NLP-Spring-2019-PQ-Man-Server.git /root/nlp
cd /root/nlp/CAu_NLP_2019 cd /root/nlp/CAu_NLP_2019