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
#!/usr/bin/python | |
import socket | |
import signal # Allow socket destruction on Ctrl+C | |
import sys | |
import time | |
import threading | |
import getopt | |
class WebServer(object): | |
""" |
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
#!/bin/bash | |
file=$1 | |
port=$2 | |
if [[ -n "$file" ]] && [[ -n "$port" ]]; then | |
{ echo -ne "HTTP/1.0 200 OK\nContent-Type: application/octet-stream\nContent-Disposition: inline; filename=\"$1\"\nContent-Length: $(wc -c < $file)\n\n"; cat $file; } | nc -l $port | |
else | |
echo "Usage: $(basename $0) <file> <port>" | |
fi |