Building a personal URL shortener in Python is a great project to practice web development, databases, and routing. Below is a minimal, functional version using Flask and SQLite. This basic version allows you to shorten URLs, store them in a database, and redirect to the original URL when the short URL is accessed.
Step-by-step: Personal URL Shortener using Flask and SQLite
✅ Requirements:
Install Flask and SQLite (SQLite comes preinstalled with Python):
🔧 Project Structure:
📄 app.py
🧾 templates/index.html
🧾 templates/result.html
▶️ How to Run:
In your terminal:
Visit http://127.0.0.1:5000 in your browser.
🛡️ Enhancements (Optional):
-
Add custom short URLs.
-
Use a better random string generator with collision checking.
-
Add analytics (click count, IP logging).
-
Use a production-grade database like PostgreSQL.
-
Deploy with Gunicorn + Nginx on a VPS or Heroku.
Would you like deployment instructions or enhancements like custom aliases or analytics tracking?