Source code of the URL shortener.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Source code of the URL shortener.

Install Your Own


  • Basic knowledge of web server configuration
  • Flask and Python experience
  • Basic SQL knowledge

Set up the MySQL Database

Create a new database on your MySQL Server and note the name. Then create the following two tables.

-- Click Logging Table
  `id`            int(11)      NOT NULL AUTO_INCREMENT,
  `ip`            varchar(50)  DEFAULT NULL,
  `alias`         varchar(20)  DEFAULT NULL,
  `dateClicked`   datetime     DEFAULT NULL,
  `userAgent`     varchar(250) DEFAULT NULL,
  `browser`       varchar(50)  DEFAULT NULL,
  `platform`      varchar(50)  DEFAULT NULL,
  PRIMARY KEY     (`id`)

-- URL Table
  `id`            int(11)      NOT NULL AUTO_INCREMENT,
  `url`           text,
  `alias`         varchar(20)  DEFAULT NULL,
  PRIMARY KEY     (`id`)

Remember the names you choose for your tables, you'll need those.

Set up

Create a file named ("database credentials")
This will contain the information for your database as well as some other miscellaneous information

server      =   "mysql host"
user        =   "mysql username"
passwd      =   "mysql password"
db          =   "mysql database"

urltbl      =   "url table name"
cltbl       =   "click logging table name"

passwords   =   ("list of passwords")

Install Requirements

Install requirements from requirements.txt with pip install -r requirements.txt
Do this from inside of your virtualenv if you plan on running this inside of one.


Inside of you'll find miscellaneous things that are specific and user specific to myself (Kyle). These will eventually be moved into the file, but for now, these must be changed manually.


Running python from the root directory of the project should now present you with:

* Running on (Press CTRL+C to quit)

Now, visiting http://localhost:5000/ in your web browser of choice should present you with a working version

Go Live

This is where the web server component of the prerequisites comes in handy. Deploy this to a web server of your choice along with your custom URL in order to have a fully working URL shortener that you can access from any web browser. If you don't own a physical server, one option is running this on virutalized on a service such as Heroku, though the free tier may be slow for these purposes.