- Make a short url valid for 2 days.
- Create virtual environment to install dependencies.
$ virtualenv venv -p python3- Activate virtual environment.
$ source venv/bin/activate- Install all the dependencies using below command.
(venv)$ pip install -r requirements.txt-
Setup PostgreSQL
- Install the postgresql database in your local computer from the official site link.
-
Create a new database using the postgresql command line
$ CREATE DATABASE abc- Change username and password for database in .env file according to your postgres configuration.
- e.g If your postgres username is 'ABC' and password is 'XYZ', then update .env file as
DB_NAME=abc
DB_USER=ABC
DB_PASSWORD=XYZ
DB_HOST=localhost
DB_PORT=5432
- Add other required setting in .env as following
URL_SIZE=4 (short url size)
LINK_VALID=5 (Number of days)
- After creating database apply migrations using below command
(venv)$ python manage.py migrate- Run project on server using below command:
(venv)$ python manage.py runserverAnd navigate to http://127.0.0.1:8000/.
- Create Short url from following api endpoint.
http://127.0.0.1:8000/api/short-n-url/create/