| LICENSE.txt | ||
| ncws.sh | ||
| README.md | ||
netcat Web Server
Serve a web page and inspect HTTP requests using netcat.
Usage
- After cloning the repository, make sure that the
ncws.hscript is executable.
$ chmod +x ncws.h
- Run the
ncws.hscript.
$ ./ncws.h
netcat web server
Listening on 0.0.0.0 8080
- In another terminal, make a request to the server using
curl.
$ curl http://127.0.0.1:8080
netcatwill print the request and send a response.
...
Connection received on localhost 40790
GET / HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/8.11.0
Accept: */*
curlshould receive the response and print it.
$ curl http://127.0.0.1:8080
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello, World!</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
- The script will then resume listening for more requests.
...
Listening on 0.0.0.0 8080
- Press
CTRL-Cto terminate the script.