This is a simple URL shortening service, written in Python using Flask and Redis.
$ nix-shell -p python3.pkgs.flask python3.pkgs.redis
[nix-shell:~/src/shortener]$ FLASK_APP=app.py flask run
* Serving Flask app "app.py"
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
$ curl -XPOST -d '{"url": "http://google.com"}' -H "Content-Type: application/json" localhost:5000/shorten_url
{"shortened_url":"http://localhost:5000/nZXzVO7i"}
$ curl http://localhost:5000/nZXzVO7i
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="b'http://google.com'">b'http://google.com'</a>. If not click the link.
$ curl -XPOST -d '{"url": "notaurl"}' -H "Content-Type: application/json" localhost:5000/shorten_url
{"error":"please supply absolute url"}