- Using Python2, Flask
-
Install requirements:
pip install -r requirements.txt
-
Run the app:
python run.py
-
Application is available at
localhost:5000
-
If you run into module import error, you can try running the app in virtualenv:
$ pip install virtualenv
$ virtualenv url_shortener
$ . url_shortener/bin/activate
$ pip install -r requirements.txt
$ python run.py
$ deactivate # Exit virtualenv
-
The home page has a form that allows you to input target URLs and create short links. If the target URL is valid, a short URL is created, user is redirected to the edit page.
-
On the edit page, user can add target URL to the current short link based on the device type (based on Werkzeug's doc on platform types).
-
Clicking on the short URL on a desktop environment short increase the number of clicks under that target on refresh. The first target added is the default for types of device that don't have specified target.
-
I tested on mobile devices by using the public IP instead of localhost. The number of clicks increased for the mobile target.
-
"All my links" page has a list of all the short links created
(The config setup is not perfect since I am new to Flask)
- Change
TEST_MODE
toTrue
inurl_shortener/config.py
- Run the test suite
py.test url_shortener/tests