To create a virtual env and install dependencies run:
pipenv shell
pipenv install
To run the server:
./manage.py runserver
There are two endpoints, one to create a short URL and another to retreive the original link from a short URL.
- Make a POST request to
/shorten-url
- POST data format:
{"url": "https://www.django-rest-framework.org/tutorial/quickstart/"}
- Example response:
{
"url": "https://www.django-rest-framework.org/tutorial/quickstart/",
"short_code": "MjY="
}
- Make a POST request to
/retreive-original-url
- POST data format:
{"short_code": "MjM="}
- Example response:
{
"url": "https://www.django-rest-framework.org/tutorial/quickstart/"
}
To run tests:
./manage.py test