A simple example of a url shortener.
Example, given a url ( EG https://www.google.com/?t=3922&usa=1&private=false )
Create a short url https://[domain]/r/[shortcode] ( EG http://localhost:8181/r/3928 )
http://[domain]/r/[code]
Example:
localhost:8181/r/3928
docker-compose up -d
^^ Then test with http://localhost:8181/
Use the container id and stream the logs
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dc81eaa56ef0 url-shortener_urlshortner-app "python server.py" 7 minutes ago Up 7 minutes
$ docker logs -f dc81eaa56ef0
After executing, you will have 2 running cointainers on your Docker host: urlshortner-app
and urlshortner-mysql
. For accessing the web application, open your browser and go to http://localhost:8181
To destroy the containers, execute:
docker-compose down --rmi all
About ~ 2 hours. I don't code python daily.