The purpose of this project is to learn and practice. As this was my first time using Python3 and Flask to build a small application I've took some ideas from: pyr/url-shortener
Simple URL shortener using:
- Calculate MD5 of the original URL
- Convert it to base64. Taking care of using only URL-valid characters.
- Crop the base64 (actually not 64 because not all characters are URL-valid) to 8 characters. This gives 64⁸ ≃ 280 trillion possible combinations.
Collisions are not detected/managed , yet.
Fastest way is to use Docker:
$ docker run -itd -p 6379:6379 redis:alpine
So now we have a Redis DB listening on localhost:6379
.
By default no credentials are set. So you can acces the DB with
$ redis-cli
127.0.0.1:6379>
$ ./turl.py
By default FLASK_PORT = 5001
. Update it in config.py
or set the set the env var FLASK_PORT
to change it.
Access localhost:5001
(or FLASK_HOST:FLASK_PORT
) with a browser.
GNU GPLv3