From 1620b1dad03f448ee467a5001a7bc60f6b47aec7 Mon Sep 17 00:00:00 2001 From: trimstray Date: Tue, 15 Jan 2019 14:50:51 +0100 Subject: [PATCH] one-liners: added 'python' to 'Programming' section - signed-off-by: trimstray --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index bfe0769..c6fa19f 100644 --- a/README.md +++ b/README.md @@ -2465,6 +2465,49 @@ _dname="google.com" ; curl -s "https://dns.google.com/resolve?name=${_dname}&typ Programming +##### Tool: [python](https://www.python.org/) + +###### Static HTTP web server + +```bash +# Python 3.x +python3 -m http.server 8000 --bind 127.0.0.1 + +# Python 2.x +python -m SimpleHTTPServer 8000 +``` + +###### Static HTTP web server with SSL support + +```bash +# Python 3.x +from http.server import HTTPServer, BaseHTTPRequestHandler +import ssl + + +httpd = HTTPServer(('localhost', 4443), BaseHTTPRequestHandler) + +httpd.socket = ssl.wrap_socket (httpd.socket, + keyfile="path/to/key.pem", + certfile='path/to/cert.pem', server_side=True) + +httpd.serve_forever() + +# Python 2.x +import BaseHTTPServer, SimpleHTTPServer +import ssl + + +httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), + SimpleHTTPServer.SimpleHTTPRequestHandler) + +httpd.socket = ssl.wrap_socket (httpd.socket, + keyfile="path/tp/key.pem", + certfile='path/to/cert.pem', server_side=True) + +httpd.serve_forever() +``` + ##### Tool: [awk](http://www.grymoire.com/Unix/Awk.html) ###### Remove duplicate entries in a file without sorting