add basic authentication and authorization. major refactor-cleanup of script. use a requirements.txt file to install some dependencies via pip.