Generates short URLs, redirects to the original URL and counts visitors for each url.
pip install -r requirements.txt
python manage.py migrate
gunicorn url_shortener.wsgi
curl -X POST "http://127.0.0.1:8000/shortener/" -H "accept: application/json" -H "Content-Type: application/json" -H "X-CSRFToken: YOUR-CSRF-TOKEN" -d "{ \"url\": \"https://example.com\"}"
{
"url": "https://example.com",
"slug": "BXaL",
"visitor_count": "2020-01-01T00:00:00Z"
}
201 Created
curl -X GET "http://127.0.0.1:8000/shortener/" -H "accept: application/json" -H "X-CSRFToken: YOUR-CSRF-TOKEN"
[
{
"url": "https://example.com",
"slug": "0GrR",
"visitor_count": 1
}
]
200 OK
curl -X GET "http://127.0.0.1:8000/r/0GrR/"
302 Found
MIT