Last active
June 24, 2018 11:04
-
-
Save stefanhaustein/d0691defbcbf1af8449c6352ae39c39e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
public class Httpd { | |
public static void main(String[] args) throws IOException { | |
ServerSocket v = new ServerSocket(8080); | |
for (;;) { | |
Socket s = v.accept(); | |
try { | |
InputStream i = new FileInputStream(new BufferedReader(new InputStreamReader(s.getInputStream())).readLine().split(" ")[1]); | |
new PrintStream(s.getOutputStream()).println("HTTP/1.0 200 OK\n"); | |
for(int b; (b = i.read()) != -1;) s.getOutputStream().write(b); | |
s.close(); | |
} catch (IOException e) {} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment