Skip to content

Django-based API service to generate short URLs with expiry, configurable link length, and PostgreSQL support.

Notifications You must be signed in to change notification settings

pc-crazy/short-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Url Shorten

Features:

  • Make a short url valid for 2 days.
  1. Create virtual environment to install dependencies.
$ virtualenv venv -p python3
  1. Activate virtual environment.
$ source venv/bin/activate
  1. Install all the dependencies using below command.
(venv)$ pip install -r requirements.txt
  1. Setup PostgreSQL

    • Install the postgresql database in your local computer from the official site link.
  2. Create a new database using the postgresql command line

$ CREATE DATABASE abc
  1. 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
  1. Add other required setting in .env as following
      URL_SIZE=4 (short url size)
      LINK_VALID=5 (Number of days)
  1. After creating database apply migrations using below command
(venv)$ python manage.py migrate
  1. Run project on server using below command:
(venv)$ python manage.py runserver

And navigate to http://127.0.0.1:8000/.

  1. Create Short url from following api endpoint.

http://127.0.0.1:8000/api/short-n-url/create/

About

Django-based API service to generate short URLs with expiry, configurable link length, and PostgreSQL support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published