📝 Playing around with netcat
This commit is contained in:
parent
58a1590583
commit
e40b10096e
5 changed files with 28 additions and 9 deletions
2
scripts/nc_play/README.md
Normal file
2
scripts/nc_play/README.md
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
This directory is simply to play around with nc. Eventually the hope is to
|
||||
replace live-server with a nc/websockets implementation in bash.
|
||||
12
scripts/nc_play/index.html
Normal file
12
scripts/nc_play/index.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>test</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="color: red;">This is a test, and this is more.</h1>
|
||||
<script type="application/javascript" src="http://localhost:8081"></script>
|
||||
</body>
|
||||
</html>
|
||||
1
scripts/nc_play/index.js
Normal file
1
scripts/nc_play/index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log('hi')
|
||||
13
scripts/nc_play/nk
Executable file
13
scripts/nc_play/nk
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
servefile="$1"
|
||||
port="$2"
|
||||
|
||||
main() {
|
||||
while :
|
||||
do
|
||||
echo -e "HTTP/1.1 200 OK\n\n$(cat "$servefile")" | nc -l -p "$port" -q 1
|
||||
done
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
servefile="$1"
|
||||
|
||||
while :
|
||||
do
|
||||
# echo -e "HTTP/1.1 200 OK\n\n$(echo '<h1>Hi there</h1>')" | nc -l -k -p 8080 -q 1
|
||||
echo -e "HTTP/1.1 200 OK\n\n$(cat "$servefile")" | nc -l -k -p 8080 -q 1
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue