hakk

software development, devops, and other drivel
Tree lined path

Python One liners

A couple of helpful(?) one liners in python, I use these for quick development or when troubleshooting and testing.

Start a static file http server in the current directory

python -m http.server

If you only want it to listen on localhost you can pass a bind parameter

python -m http.server --bind 127.0.0.1

It’s also possible to specify a port (default is 8000)

python -m http.server --bind 127.0.0.1 8080

If you need an smtp server for trouble shooting, it’s possible to fire one of those up in one line. It will just print all output to the terminal but most of the time that works just fine for my purposes. You my need elevated privileges to run on port 25 or any other privileged port.

python -m smtpd -n -c DebuggingServer localhost:25

Know of other helpful python one liners? Let me know, please.