I had heard about Redis Database in a forum somehwere. So I dived into a rabbit hole and some considerable time later, I got out having made this project.
I really like working with Redis. It is simple to use and set up, has limited but very useful features and works well with most small apps.
I also liked using Flask, this was the first time I had actually used it, not just experimented with. Flask is lightweight and gets out of your way, allowing flexibility to use what I want to work with.
The site front-end is based on a Bootstrap default theme which had to be adjusted alooot for making it responsive.
The client side JS with Jquery was a bit of a pain to work with, but once I got all pieces together, the code was managable.
This was my first time experimenting with Flask, I had combed through the docs and adjusted it enough to just work.
The algorithms are actually pretty simple :
base64-ish algorithm, but with a few characters removed, like
?to make it URL friendly , hence it is actually
base62. The index or position of the long URL entry in the database is returned as a
base62string. The same is decoded while resolving the short URLS.
randommodule to generate words with specified number of syllables. And since syllables are made up of either:
Thus the Fake word is generated.
Flask is actually pretty cool, it is very flexible, unlike Django, so I can mix and match with components to replace if need be. I used the
redis module for the first time.
Redis is actually pretty awesome, it is simple and straightforward and a breeze to install and use. Locally it was simple, but on Heroku it needed some adjustment.
The database has just two data types:
I deployed the whole thing on Heroku with the Free Plan. It is a very useful service.
Heroku doesnt have native support for Redis, but it does have an addon provided from the makers themselves. It was still much easier to set up than any MySQL database.
What the site does is, it takes a long URL and shortens it. Simple.
The site has 3 modes of operation:
The result is based on the option chosen. The link is generated and sent back via AJAX as shown below..
There is also an API for use, but it allows default mode only.
I enjoyed working on this project and I learned quite a few things like :