Source code of the frst.xyz URL shortener.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
templates
.gitignore
LICENSE
README.md
jsonapi.py
main.py
requirements.txt

README.md

frst.xyz

Source code of the frst.xyz URL shortener.

Install Your Own

Prerequisites

  • 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
CREATE TABLE [INSERT_TABLE_NAME] (
  `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
CREATE TABLE [INSERT_TABLE_NAME] (
  `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 dbc.py

Create a file named dbc.py ("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.

Customizing

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

Test

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

* Running on http://0.0.0.0:5000/ (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.

License

See LICENSE