Url shortener API with Django and django rest framework.
Project consists to allow a user to transform a long web url into a pattern-consistent (encoded) small url easy to share and remember.
At the same time the user is allowed to transform back (decode) the small url into the original url
It is partly tested as only and was developed as showcase only.
How Url Shortener API Works:
-
You can send (POST) a full url and retrieve a small encoded one with tier.app as the base web service url.
Eg. POST https://stark-scrubland-55374.herokuapp.com/shorten-url/ with https://www.newsbytesapp.com/ result: stark-scrubland-55374.herokuapp.com/qyMX6k (6 digits id)
-
You can get the original url with the encoded url on a GET request (done in previous step)
Eg. GET stark-scrubland-55374.herokuapp.com/qyMX6k result: https://www.newsbytesapp.com/
-
- Installing Django API App
-
- Available Endpoints
-
- thoughts on improving it.
- Testing
- UI
- Database
- thoughts on improving it.
- Clone repository and go inside the repository folder "url-shortener-api"
git clone https://github.com/shadowpint/shotput.git
- Create you virtualenv and install the packages
pip install -r requirements.txt
- Initialize database and create the database mapping used for persistance in the url shortener API.
python manage.py makemigrations
- Apply the database mapping from the app to the database; migrate the database.
python manage.py migrate
- Run the application.
python manage.py runserver
URI Example: http://localhost:8000/shorten-url/
Available Methods | URI | Example URL | |
---|---|---|---|
Project Endpoints | |||
1. | POST |
shorten-url/ |
http://localhost:8000/shorten-url |
2. | GET |
/<short_id> |
http://localhost:8000/<short_id> |
To interact and start using the API, you will need a tool send HTTP requests to your api. I have develop a list of request to test and interact with the api with Postman. You will need to download the Postman Desktop app or the Web Browser plug in for Chrome. Click on the button below to guide you to download the app with the list of request I have developed to test the api fast.
- integrate functional testing into the django app
- add personalized assert messages and setup error message separated structure
- set up error handling and eliminate chunks of ugly try:
- set up rest full service (if required (del, list, ...))
- do short url should expire set up?
- refactor
- set up a mysql db
- set up and split stats and ShortUrl models
- set up automated testing pipeline
Technology Stack | ||
---|---|---|
Python | Back-End | |
Django | Web Framework | |
Django Rest Extension | API Django Extension | |
SQLite | Database | |
Postman | HTTP requests app |