Corrected some problems, and converted it into to a Flask application

Corrected the url, used requests instead, converted the script into a Flask application to be able to serve it as a web application or build and API on top of it.

Important note though, a file is created evey time a request is issued to the Flask application, so this needs to be modified before releasing on production servers to avoid any sudden file system failures.