This content originally appeared on DEV Community and was authored by Alexander
Modern web servers include millions of lines of code, but today you will find that it only takes four lines to write the simplest HTTP server.
No, it's not going to be something boring like this:
new WebServer().start();
Let's say we want Mom to see our greeting when she visits our server.
Do you have the latest version of VS Code open? If so, close it, you won't need it! ✋
Open your favorite text editor. Name your file: Mom.txt
Did you feel how good your soul felt?...
Ok, we won't complicate things, we'll take a text editor and write four magic lines:
GET / HTTP/1.1
HTTP/1.1 200 OK
Content-Type: text/html
Hello, Mom!
Better than "Hello, world!", Isn't it? ?
Our server is ready! Double click on the file icon to start your server...
File opened in a text editor?! ?
Shit... It's not working! What to do?
Ok, I'll whisper the name of the some tool to you, but first, promise not to tell anyone about this magic wand. Not even your mother. You promise?
Write it down, then: DeepfakeHTTP
Download it and start your world's simplest HTTP server from the command line:
java -jar df.jar Mom.txt
Use a browser to check whether the server is running: http://localhost:8080
Oh, I forgot to tell you! You must have Java version 15 or higher installed on your computer.
Are you still here?! Hurry up and run and argue with someone about writing a 4-line HTTP server! ???
This content originally appeared on DEV Community and was authored by Alexander

Alexander | Sciencx (2021-08-31T19:03:45+00:00) Mom, I wrote the world’s simplest HTTP server!. Retrieved from https://www.scien.cx/2021/08/31/mom-i-wrote-the-worlds-simplest-http-server/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.