Skip to content

A simple URL shortener based on Django framework and MySQL for ITW2 course assignment

Notifications You must be signed in to change notification settings

0xkn1gh7/URLShortener-ITW2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

URLShortener

A simple URL shortener based on Django framework and MySQL for ITW2 course assignment.

Features

Done for the assignment

  • Generate a unique 8 digit token for each URL
  • If a URL already has a short URL generated, then display that to user
  • Display a table containing all short URLs and corresponding original URLs

For future *fun* purposes

  • Add functionality for custom token, if it is available
  • Improve UI?
  • Bash script to automate install process

Steps to reproduce

This has been tested on Ubuntu 22.04 and Python 3.10

$ git clone https://github.com/kn1-gh7/URLShortener-ITW2.git
$ cd URLShortener-ITW2
  • Create a python virtual environment and activate it
$ python3 -m venv venv
$ source venv/bin/activate
  • Install build dependencies
(venv)$ sudo apt update
(venv)$ sudo apt install python3.10-dev libmysqlclient-dev build-essential
(venv)$ export MYSQL_CFLAGS="$(mysql_config --cflags)"
(venv)$ export MYSQL_LDFLAGS="$(mysql_config --libs)"
  • Install requirements
(venv)$ pip install pip setuptools -U
(venv)$ pip install -r requirements.txt
  • Setting database config
# After installing mysql and setting root password
(venv)$ mysql -u root -p
# Choose a database name
mysql> CREATE DATABASE urlshortener_db;
mysql> exit
# Open src/urlshortener/urlshortener/settings.py and go to the following section
..
DATABASES  = {
	'default': {
		'ENGINE': 'django.db.backends.mysql',
		'NAME': 'urlshortener_db', #Set the name of database here
		'USER': 'root',
		'PASSWORD': 'password', #Set the password for mysql root user here
		'HOST': 'localhost',
		'PORT': '3306',
	}
}
..
  • Make migrations and run server
# In the src/urlshortener directory
(venv)$ python manage.py makemigrations
(venv)$ python manage.py migrate
(venv)$ python manage.py runserver

Done! You have the app running!

About

A simple URL shortener based on Django framework and MySQL for ITW2 course assignment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published