A simple URL shortener built using Django and PostgreSQL.
- Shorten URLs
- Redirect to original URLs
- Get top visited domains
- Get metrics
- Clone the repository
- Run
docker compose up --build
to start the application
- Clone the repo
- copy the contents of
.env.docker
to.env
. - Install the requirements from
requirements.txt
. - Run the dev server by the command
python manage.py runserver
curl --location 'https://awesomeurlshortner.vercel.app/shorten/' \
--header 'Content-Type: application/json' \
--data '{
"url": "facebook.com"
}'
shorten/
(POST): Takes a URL in the request body, validates it, creates or retrieves a shortened URL, and returns the shortened URL in a JSON response.metrics/
(GET): Returns a JSON response with the top 3 most common domains from all shortened URLs in the database.<str:path>/
(GET): Takes a shortcode from the URL path, looks it up in the database, and redirects to the original URL associated with that shortcode.