Shortify is a modern, minimal, and fully-functional URL shortener built using Flask and MongoDB. It allows you to shorten URLs, customize short codes, track click counts, and optionally set expiration times.
- π Shorten long URLs into compact links
- βοΈ Optional custom short codes
- β³ Optional expiration (in hours)
- π Real-time click tracking
- π Copy-to-clipboard button
- π¨ Clean, responsive Bootstrap frontend
- β 404 page for broken links
- Backend: Flask
- Database: MongoDB
- Frontend: HTML, Bootstrap 5, JavaScript
- Others:
pymongo
,python-dotenv
shortify/
βββ app/
β βββ __init__.py
β βββ config.py
β βββ models.py
β βββ routes.py
β βββ utils.py
βββ templates/
β βββ index.html
β βββ 404.html
βββ static/ # Optional for CSS/JS
βββ run.py
βββ requirements.txt
βββ .env
βββ README.md
git clone https://github.com/Nuraj250/shortify
cd shortify
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt
Create a .env
file in the root directory:
MONGO_URI=mongodb://localhost:27017/
DB_NAME=shortify
BASE_URL=http://localhost:5000
python run.py
Visit http://localhost:5000
in your browser π
Shortens a URL.
{
"url": "https://example.com/long-url",
"custom_code": "mycustomcode", // optional
"expires_in": 24 // optional (in hours)
}
{
"short_url": "http://localhost:5000/mycustomcode",
"custom_code": "mycustomcode",
"expires_in": 24
}
Redirects to the original URL, or returns a 404 page if invalid or expired.
Returns click stats for a short URL.
{
"short_code": "abc123",
"clicks": 5
}
- π Admin dashboard for URL management
- π¦ Docker support for deployment
- π Analytics with charts
- π¬ QR code generation
MIT License β use it freely!
Pull requests and feature ideas are welcome! Drop a β if you like the project.