Signed-off-by: DaliBradai <Dali.bradai@yahoo.com>
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..1938c4d
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="owner.project.facets" value="java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
diff --git a/.gitignore b/.gitignore
index 32858aa..5551970 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
+/build/
diff --git a/.project b/.project
new file mode 100644
index 0000000..4ade233
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TestGerritHub</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..f4ef8aa
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/src/iit/administionweb/main/Main.java b/src/iit/administionweb/main/Main.java
new file mode 100644
index 0000000..9ad33b5
--- /dev/null
+++ b/src/iit/administionweb/main/Main.java
@@ -0,0 +1,12 @@
+package iit.administionweb.main;
+
+import iit.administrationweb.serveur.Serveur;
+
+public class Main {
+
+ public static void main(String args[]){
+
+ Serveur.create();
+ }
+
+}
diff --git a/src/iit/administrationweb/serveur/Serveur.java b/src/iit/administrationweb/serveur/Serveur.java
new file mode 100644
index 0000000..b6ce552
--- /dev/null
+++ b/src/iit/administrationweb/serveur/Serveur.java
@@ -0,0 +1,28 @@
+package iit.administrationweb.serveur;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class Serveur {
+
+ public static void create() {
+ try {
+ ServerSocket serverSocket = new ServerSocket(8000);
+ while (true) {
+ try {
+ Socket socket = serverSocket.accept();
+ ThreadedEchoServer serveurThread = new ThreadedEchoServer(
+ socket);
+ serveurThread.start();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/iit/administrationweb/serveur/ThreadedEchoServer.java b/src/iit/administrationweb/serveur/ThreadedEchoServer.java
new file mode 100644
index 0000000..9f0dbfa
--- /dev/null
+++ b/src/iit/administrationweb/serveur/ThreadedEchoServer.java
@@ -0,0 +1,80 @@
+package iit.administrationweb.serveur;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.Socket;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ThreadedEchoServer extends Thread {
+
+ private Socket socket;
+ public static final String webFolder = "/home/dali/serveur";
+ PrintWriter printWriter;
+
+ public ThreadedEchoServer(Socket socket) {
+ super();
+ this.socket = socket;
+ }
+
+ @Override
+ public void run() {
+
+ super.run();
+ try {
+ /*lecture de l'input du serveur (venant du client)*/
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ socket.getInputStream()));
+
+
+ String input = reader.readLine();
+ String[] intupDecoup=input.split(" ");
+ input=intupDecoup[1];
+ File f =new File(webFolder+input);
+ printWriter = new PrintWriter(socket.getOutputStream());
+ if(f.exists()){
+ printWriter.print("HTTP/1.0 200 OK");
+ printWriter.println("Content-Type : text/html");
+ printWriter.println();
+
+ String chaine="";
+
+ //lecture du fichier texte
+ try{
+ InputStream ips=new FileInputStream(f);
+ InputStreamReader ipsr=new InputStreamReader(ips);
+ BufferedReader br=new BufferedReader(ipsr);
+ String ligne;
+ while ((ligne=br.readLine())!=null){
+ System.out.println(ligne);
+ chaine+=ligne+"\n";
+ }
+ br.close();
+ }
+ catch (Exception e){
+ System.out.println(e.toString());
+ }
+
+ printWriter.println(chaine);
+
+ }
+
+
+ printWriter.flush();
+ socket.close();
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+}