Saturday, July 15, 2023

GoShrt: A simple URL shortener

  by Joseph Anthony C. Hermocilla, Principal Consultant



URL Shorteners allow users to convert very long URLs into shorter ones that are easier to remember. While preparing my presentation for a workshop, I decided that I could just make Heralli's own URL shortener instead of using popular products such as bit.ly and tiny.url. The result is GoShrt, a Flask App with SQLite3 as the database. The codebase is largely borrowed from this very nice DO tutorial. I Docker-ized the app so that it is easier to deploy.  I also added Captcha to prevent bots from abusing the app.  

One of the challenges I encountered while developing and deploying GoShrt is how to persist the contents of the database across container restarts. The solution is to use docker volumes. Only the source code for the app is placed in the container, the database is in a volume that is mounted on the container. 

Shown below are the contents of docker-compose.yml and Dockerfile, respectively, to achieve this.






At the production server, the local volume is created as shown below.



I enjoyed working on GoShrt. Using it to shorten URLs will also help in advertising Heralli. At the tech side, Python3, Flask, and SQLite3 will surely be my go-to tech stack when developing simple web apps with minimal performance and scalability requirements.


Contact us if you need help building web apps in Flask. We'd be glad to help.