🔗 URL Shortener
[](https://www.python.org/downloads/) [](https://flask.palletsprojects.com/) [](LICENSE) [](http://makeapullrequest.com) A modern, feature-rich URL shortening service built with Flask and modern web technologies. Transform long URLs into memorable short links with comprehensive analytics. [Features](#-features) • [Demo](#-live-demo) • [Installation](#-installation) • [API](#-api-reference) • [Contributing](#-contributing)✨ Features
🔹 Instant Shortening: Convert long URLs into concise, shareable links
🔹 Custom Aliases: Create branded short URLs for better recognition
🔹 Expiration Control: Set expiry dates for temporary links
🔹 Rich Analytics: Track clicks, locations, devices, and more
🔹 Visual Insights: Interactive charts powered by Chart.js
🔹 Real-time Updates: Monitor URL performance in real-time
🔹 Responsive Design: Perfect experience across all devices
🚀 Live Demo
Experience the application in action: Live Demo
🛠️ Tech Stack
Backend
- Python: Core programming language
- Flask: Web framework
- SQLAlchemy: ORM for database operations
Frontend
- Bootstrap 5: Responsive UI framework
- Chart.js: Interactive data visualization
- Font Awesome: Beautiful icons
Database & Tools
- SQLite: Lightweight database
- user-agents: Device detection
📦 Installation
Clone the repository
git clone https://github.com/hassanrrraza/url_shortener.git cd url_shortenerSet up virtual environment
# Windows python -m venv venv venv\Scripts\activate
# macOS/Linux python -m venv venv source venv/bin/activate
3. **Install dependencies**
```bash
pip install -r requirements.txt
Initialize database
python init_db.pyStart the server
python run.pyVisit
http://localhost:5000in your browser
📝 API Reference
Create Short URL
POST /api/shorten
| Parameter | Type | Description |
|---|---|---|
url |
string |
Required. URL to shorten |
custom_alias |
string |
Custom alias for the URL |
expiry_date |
string |
Expiration date (ISO format) |
Get URL Analytics
GET /api/analytics/:id
Delete URL
DELETE /api/urls/:id
📂 Project Structure
url_shortener/
├── app/ # Application package
│ ├── models.py # Database models
│ ├── routes.py # API endpoints
│ ├── static/ # Static assets
│ └── templates/ # HTML templates
├── instance/ # Instance data
├── requirements.txt # Dependencies
└── run.py # Entry point
🤝 Contributing
Contributions are what make the open source community amazing! Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
🔮 Future Enhancements
- [ ] User authentication system
- [ ] QR code generation
- [ ] Password-protected links
- [ ] Bulk URL shortening
- [ ] Advanced analytics export
- [ ] API rate limiting
- [ ] Custom domain support
📄 License
Distributed under the MIT License. See LICENSE for more information.
👏 Acknowledgements
📬 Contact
Hassan Raza - @hassanrrraza
Project Link: https://github.com/hassanrrraza/url_shortener
⭐ Star this repo if you find it helpful!
Log in or sign up for Devpost to join the conversation.