Skip to content

martynawitkowska/url_shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener

Coverage Report Beerware License

A Django URL shortener app is a web application that generates short, customized links that redirect to longer URLs. It uses Django and a database to store original and short URLs, and may incorporate third-party services for URL shortening. The app is useful for simplifying the sharing of links online.

Demo

Shortener Demo

Tech Stack

Server: Python, Django, Django Rest Framework, Pytest, Docker, Postgres

Run Locally

Clone the project

  git clone git@github.com:martynawitkowska/url_shortener.git

Go to the project directory

  cd url_shortener

Set environmental variables

Instructions for setting variables

  cp ./envs/api.default.env ./envs/api.env
  cp ./envs/postgres.default.env ./envs/postgres.env
  # set variable values

Start Docker Containers

  docker compose up

Load test data

docker compose exec api python manage.py loaddata fixtures/test_links.json

Go to your client and type

    http://0.0.0.0:8000/api/schema/swagger-ui/

Here are links from test data file that you can visit:

Environment Variables

To run this project, you will need to add the following environment variables to your ./envs/api.env file

DJ_SECRET_KEY= # Django Secret Key for CSRF link
DJ_DEBUG= # Production development mode
DJ_ALLOWED_HOSTS= # Allowed Hosts for Django

DJ_SU_NAME= # Default superusername
DJ_SU_EMAIL= # Default superuser email
DJ_SU_PASSWORD= # Default superuser password

Generating DJ_SECRET_KEY in console or here secret key generator:

from django.core.management.utils import get_random_secret_key
get_random_secret_key()

Postgres variables ./envs/postgres.env

POSTGRES_USER= # Postgres root user
POSTGRES_PASSWORD= # Postgres root password
POSTGRES_DB= # Database name
POSTGRES_HOST= # Database host: set to docker compose swervice name
POSTGRES_PORT= # Database port

DB_CONNECTION_STRING=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}

Running Tests

To run tests, run the following command

  docker compose exec api pytest

Cov Report

Authors

🔗 Links

portfolio linkedin twitter

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published