Skip to content

A lightweight and efficient URL shortener built with Python and Flask. Convert long links into short, track analytics, and generate QR codes effortlessly! πŸš€

Notifications You must be signed in to change notification settings

Nuraj250/Shortify-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— Shortify – Flask URL Shortener

Shortify UI Screenshot

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.


πŸš€ Features

  • πŸ”— 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

🧱 Tech Stack

  • Backend: Flask
  • Database: MongoDB
  • Frontend: HTML, Bootstrap 5, JavaScript
  • Others: pymongo, python-dotenv

πŸ“‚ Project Structure

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

βš™οΈ Setup Instructions

1. Clone the Repo

git clone https://github.com/Nuraj250/shortify
cd shortify

2. Create a Virtual Environment

python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

3. Install Dependencies

pip install -r requirements.txt

4. Set Up Environment Variables

Create a .env file in the root directory:

MONGO_URI=mongodb://localhost:27017/
DB_NAME=shortify
BASE_URL=http://localhost:5000

5. Run the App

python run.py

Visit http://localhost:5000 in your browser πŸŽ‰


πŸ“‘ API Endpoints

POST /shorten

Shortens a URL.

Request Body (JSON):

{
  "url": "https://example.com/long-url",
  "custom_code": "mycustomcode",    // optional
  "expires_in": 24                  // optional (in hours)
}

Response:

{
  "short_url": "http://localhost:5000/mycustomcode",
  "custom_code": "mycustomcode",
  "expires_in": 24
}

GET /<short_code>

Redirects to the original URL, or returns a 404 page if invalid or expired.


GET /<short_code>/stats

Returns click stats for a short URL.

Response:

{
  "short_code": "abc123",
  "clicks": 5
}

πŸ›  Future Ideas

  • πŸ” Admin dashboard for URL management
  • πŸ“¦ Docker support for deployment
  • πŸ“Š Analytics with charts
  • πŸ’¬ QR code generation

πŸ“Έ UI Preview

Shortify UI Screenshot


πŸ“„ License

MIT License β€” use it freely!


🀝 Contribute

Pull requests and feature ideas are welcome! Drop a ⭐ if you like the project.

About

A lightweight and efficient URL shortener built with Python and Flask. Convert long links into short, track analytics, and generate QR codes effortlessly! πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published