A simple URL Shortner, easy to deploy and use, developed using Python
, Flask
, and SQLiteDict
.
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)
/
-GET
request does not accept nor expects any arguments nor parameters. Simply returns the homepage template to the clients./
-POST
request requires the request to includeurl
parameter with valid URL as a string. Utilizes Django's URL validation regex to verify URL.
- URL Translation
/<ID>
-GET
requires shortened ID generated from the/
'sPOST
method. 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)