https://github.com/mnowotka/babyshortener
simple url shortener implemented using Flask
https://github.com/mnowotka/babyshortener
flask url url-shortener
Last synced: 6 months ago
JSON representation
simple url shortener implemented using Flask
- Host: GitHub
- URL: https://github.com/mnowotka/babyshortener
- Owner: mnowotka
- License: mit
- Created: 2017-10-07T16:13:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-10-06T22:20:16.000Z (9 months ago)
- Last Synced: 2025-10-07T00:17:46.893Z (9 months ago)
- Topics: flask, url, url-shortener
- Language: Python
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babyshortener
Simple URL shortener implemented using Flask
[](https://travis-ci.org/mnowotka/babyshortener)
Persistence layer provided by SQLAlchemy (`flask_sqlalchemy`). API Resource class provided by `flask-restful`
## How to install?
Run:
```
git clone git@github.com:mnowotka/babyshortener.git
cd babyshortener
pip install .
pip install -r requirements.txt
```
Or:
```
pip install git+https://github.com/mnowotka/babyshortener.git
```
## How to test?
Run:
```
python tests/test_shortener.py
```
## How to run development server?
If installed by cloning `GitHub` repo, add project root directory to `PYTHONPATH` and run:
```
python babyshortener/run_shortener.py
```
If installed via `pip`, the `run_shortener` command should be available
## How to make request using `curl`?
To shorten:
```
curl -H "Content-Type: application/json" -X POST -d '{"url": "www.google.com"}' http://localhost:5000/shorten_url
```
To redirect:
```
curl http://localhost:5000/1VV
```
## How to configure to scale?
1. Provide your own settings file and configure `SQLALCHEMY_DATABASE_URI` to point to the production database
2. Deploy behind gunicorn & NGINX (https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04)
```
export BABYSHORTENER_SETTINGS=/path/to/settings.cfg
gunicorn --bind localhost:8080 --workers 4 'babyshortener.run_shortener:main'
```
3. Deploy on multiple machines behind a load balancer
4. Add a cache layer