A demo application for a very simple URL shortening service
The app relies on:
Pip:
pip install url_shortener
Pypi:
https://pypi.python.org/pypi/url_shortener
Manual:
python setup.py install
You can either modify the config.py
file or provide environment
variables to configure url_shortener
. The following environment
variables can be tweaked:
REDIS_HOST
: Address at which the redis server lives, defaults to127.0.0.1
.REDIS_PORT
: Port on which to contact redis, defaults to6379
.URL_PREFIX
: URL scheme for your short url hostLISTEN_HOST
: Address to bind to for the short url serviceLISTEN_PORT
: Port to bind toRIEMANN_HOST
: Address to use to contact riemann, defaults to127.0.0.1
RIEMANN_PORT
: Port to use to contact riemann, defaults to5555
RIEMANN_PROTOCOL
: Riemann protocol to use, defaults toUDP
LOG_FILE_PATH
: Where to log, no defaultsLOG_LEVEL
: level at which to log, defaults toDEBUG
When not run in debug mode, the application will output logs for consumption by logstash, using logstash_formatter
The service can simply be started by invoking: url-shortener
, alternately deployments
can be done with gunicorn. To start the service with gunicorn with 8 worker processes for
instance, the following can be used:
gunicorn -w 8 --log-file=/var/log/url-shortener/gunicorn.log --log-level=info url_shortener:app