A simple URL Shortner, easy to deploy and use, developed using Python, Flask, and SQLiteDict.
The Flask application is set to run in port 5000 by default, I have set port 2000 to route to 5000 in docker-compose.yaml file.
Simply running the command, docker compose up --build -d from within the repository root.
Deployment is easy as this project relies in three (3) python libraries. Ensure python is installed v2 or v3 does not matter in our case.
Head to the project's root and install the necessary libraries using pip install -r requirements.txt.
Once all libraries are installed, simply run it with FLASK_APP=main.py FLASK_ENV=production flask run for production purposes or FLASK_APP=main.py FLASK_ENV=development flask run for development purposes.
There are two main routes at the time of development, main page and the URL translation page. The main page handles both GET and POST requests whereas, the translation page only handles GET requests.
- Homepage (root)
/-GETrequest does not accept nor expects any arguments nor parameters. Simply returns the homepage template to the clients./-POSTrequest requires the request to includeurlparameter with valid URL as a string. Utilizes Django's URL validation regex to verify URL.
- URL Translation
/<ID>-GETrequires shortened ID generated from the/'sPOSTmethod. It checks the passed<ID>against the database and returns a temporary redirect to the translated URL.
Rate limitation has been put in place to avoid spams and irregular requests, using a nifty Python library called Flask-Limiter.
/-GET- No limitations are put in place for this route and method./-POST- 1 request per second./<ID>-GET- 1 request per second. (I've Been receiving high amount of irregular requests in this route)