A simple but awesome URL shortener app!
Report Bug
·
Request Feature
Table of Contents
There are already many great URL shortener apps available for free on the internet, however, I wanted to build my own custom one! Even though this is a fairly simple project, It's a great opportunity to learn either new technologies or improve in the ones that you already know.
ULR shorteners work through a technique that goes by the name of redirecting or forwarding. It allows for multiple ULRs to link to the same web page which, under certain circumstances is really useful. Once a web browser attempts to open a ULR which has been redirected, a page with a different ULR is opened.
If you'd like to try out the project for yourself, feel free to read the getting started section.
This project was built using the following technologies:
To get a local copy of the project up and running follow these simple steps listed below.
-
Python
Python can be downloaded from here - version 3.8 or higher is recommended. To check if you have Python installed run the following command:
python --version # or python3 --version
-
Pip
Pip (Python's package manager) is also required for this project. It usually comes with Python. To check if you have Pip run:
pip --version # or pip3 --version
-
Pipenv
This project uses Pipenv's virtual enviroments. To install Pipenv run the following command:
pip install pipenv
-
Clone the repository
# Through SSH git clone git@github.com:Frakko/Tinify.git # Through HTTPS git clone https://github.com/Frakko/Tinify.git
-
CD in to the project folder:
cd Tinify
-
Start Pipenv's virtual enviroment:
pipenv shell
-
Install the required Python packages:
pipenv install # or pipenv sync
-
Create the Sqlite database:
-
In the
settings.py
file change the constantSQLALCHEMY_DATABASE_URI
to a hard coded database link that looks like this:sqlite:///db.sqlite3
(SQLite does not impose any naming requirements, thus you can name the database as you wish). This will later on be loaded from an enviroment variable, however those variables get loaded only onceflask run
is called, therefore we would have some issues when creating the database. -
Open then the Python shell in your terminal by running the
python
command. -
In the shell, write the following lines:
from url_shortener import create_app from url_shortener.extensions import db db.create_all(app=create_app())
-
-
Now that the database is created, create a
.env
file and add to it the following line, so that it will be loaded by this enviroment variable:DATABASE_URL=sqlite:///your_database_name_here
-
The project is set up! To run it, type:
flask run
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. See contributing for more informations.
Distributed under the MIT License. See LICENSE
for more information.
If you'd like to contact me, feel free to message me on either one of the follwing networks:
- Twitter - @Frakko
- Discord - Frakko#0001