TinyURL-like url shortener with qrcode.
- Implemented base62 encoding and twitter snowflake generate unique ID to avoid hash collisions.
- Using AWS dynamoDB as database storing unique ID as key and original URL as value.
- Using Redis cloud to cache most frequence used short URL to original URL conversion to increase high queries performance and reduce database workload.
- Implemented LRU caching algorithm locally to avoid repeatly generating short URL for the same original URL.
Python Flask
Jinja
HTML, CSS
AWS dynamoDB
Redis Cloud
AWS ec2
pip install boto3 flask flask_login redis pyqrcode python-dotenv requests
- Install and start apache2 or httpd
- Install
sudo yum install mod_wsgi
- Clone the repository into
/var/www/
- Modify the
flaskapp.wsgi
as needed - Add the following script to the server configuration file
- Restart your apache or httpd
<VirtualHost *:80>
ServerName <ServerName>
ServerAdmin <ServerAdmin>
SetEnv AWS_ACCESS_KEY_ID <Your AWS ID>
SetEnv AWS_SECRET_ACCESS_KEY <Your AWS KEY>
SetEnv REDIS_HOST <Your Redis Host>
SetEnv REDIS_PORT <Your Redis port>
SetEnv REDIS_PWD <Your Redis password>
SetEnv DOMAIN <Your server domain ex: http://www.example.com/>
WSGIScriptAlias / /var/www/babyURL/flaskapp.wsgi
<Directory /var/www/babyURL/babyURL/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/babyURL/babyURL/static
<Directory /var/www/babyURL/babyURL/static/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
- Configure AWS credentials with aws cli
- Add
.env
the project root directory
REDIS_HOST = '<Your Redis host>'
REDIS_PORT = <Your Redis port>
REDIS_PWD = '<Your Redis password>'
DOMAIN = '127.0.0.1:5000/'
$ export FLASK_APP=flaskapp.py
$ flask run
Jamila
Haoran He
Liz Calderon
Musharrat Chowdhury
Sadika
Designing a URL Shortening service like TinyURL
如何将一个长URL转换为一个短URL
短 URL 系统是怎么设计的
python-snowflake by cablehead
Boto3 and Flask Demystified