Latest files with updates including GCP and other new features are in the GCP folder.
For more information, check the GCP version section below.
URL shortening web service which provides short aliases and custom aliases redirecting to original URLs.
Initial code only uses
- Python
- Flask
and is a very simple web application which shortens a URL by creating a short URL alias with a 6 characters long generated key.
Instead of using a Web database, it stores all the information (original URLs and aliases) to a JSON file and uses a text file to check existing keys to avoid duplication.
In addition to the short link feature, 1. default expiration time, 2. custom link feature, 3. custom expiration feature and 4. simple link analysis were added.
Users can create a custom URL alias with characters of their choice and can also set a custom expiration date to both short links and custom links.
Instead of using JSON, it uses a NoSQL document database GCP Firestore to manage all the data by deploying the application to GCP App Engine.
(to see an example : https://short-321807.an.r.appspot.com/)
This project is built using the following frameworks/services
- Flask
- GCP Firestore
- GCP App Engine
- unittest
gRPC(work in progress)
$ pip install python-dateutil
$ pip install Flask
follow this document for setup
$ pip install --upgrade google-cloud-firestore
follow this document for setup
- App Engine Cron Service
follow this document for setup
- clone this repository
$ git clone https://github.com/mikako-shirai/URL-shortening-service.git
- create and activate a virtual environment
$ python3 -m venv venv
$ . venv/bin/activate
(to deactivate)
(venv)$ deactivate
- install Flask in the virtual environment
(venv)$ python3 -m pip install flask
- run main.py
(venv)$ pytho3 main.py
- go to http://127.0.0.1:5000/ to view the application
- clone this repository
$ git clone https://github.com/mikako-shirai/URL-shortening-service.git
- move to GCP directory
$ cd GCP
- set up Firestore
$ export GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH"
*replace KEY_PATH with the path of the JSON file that contains your service account key
- upload cron jobs to App Engine
$ gcloud app deploy cron.yaml
- deploy the application to App Engine
$ gcloud app deploy
- go to https://YOUR_PROJECT_ID.an.r.appspot.com/ to view the application
(to run unit tests)
$ python3 -m unittest tests/suite.py