My demo URL shortener (GH repo here) is a REST API accepts a regular URL via POST and returns a short code that can be used to get a redirect to the original URL. Users of the API receive a short code and a secret administrative key that they can use to check usage statistics for that short code and optionally delete the short code so it won’t work anymore.
Example of providing a full URL to get a short code:
After visiting https://www.timstewart.io/fastapi-demo-url-shortener/FX931 several times in my browser, I can check the stats for this short URL using the secret administrative key I was issued when creating it:
- Python + FastAPI
- SQLite3 for persistent storage of short codes, URLs, and usage stats
- Nginx + gunicorn for web service