Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mmedoo/django-url-shortener
Simple Django URL Shortener App.
https://github.com/mmedoo/django-url-shortener
djnago orm python sqlite3
Last synced: 6 days ago
JSON representation
Simple Django URL Shortener App.
- Host: GitHub
- URL: https://github.com/mmedoo/django-url-shortener
- Owner: mmedoo
- Created: 2024-07-17T22:53:38.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-07-30T14:04:43.000Z (7 months ago)
- Last Synced: 2024-12-12T21:08:18.327Z (2 months ago)
- Topics: djnago, orm, python, sqlite3
- Language: Python
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
![Django](https://img.shields.io/static/v1?label=Django&message=4.2.3&color=092E20&labelColor=white&logo=django&logoColor=092E20)
![SQLite](https://img.shields.io/static/v1?label=SQLite&message=3.41.2&color=white&labelColor=black&logo=sqlite&logoColor=white)
![Jupyter](https://img.shields.io/static/v1?label=Jupyter&message=1.0.0&color=orange&labelColor=white&logo=jupyter)
![PIP](https://img.shields.io/static/v1?label=PIP&message=23.1.2&color=yellow&labelColor=3775A9&logo=pypi&logoColor=white)# Django URL Shortener
## Table of Contents
- [🌟 Introduction](#introduction)
- [⚙️ Installation](#installation)
- [🚀 Usage](#usage)
- [📦 Dependencies](#dependencies)
- [🔧 Configuration](#configuration)
- [📚 Documentation](#documentation)
- [Views](#views)
- [📬 API Endpoints](#api)
- [Jupyter Notebook](#jupyter-notebook)
- [❗️ Troubleshooting](#troubleshooting)🌟 Introduction
Django app to shorten URLs.
⚙️ Installation
To get the project up and running locally on your machine, follow these steps:
1. **Clone the repository:**
```sh
git clone https://github.com/mmedoo/django-url-shortener.git
cd django-url-shortener
```2. **Set up a virtual environment:**
```sh
python3 -m venv venv
source venv/bin/activate
```3. **Install dependencies:**
```sh
pip install -r requirements.txt
```4. **Run migrations:**
```sh
python manage.py migrate
```5. **Start the development server:**
```sh
python manage.py runserver
```
🚀 Usage
### Shorten a URL
1. Navigate to the home page.
2. Enter the URL you want to shorten in the provided form.
3. Click the "Shorten URL" button.
4. The shortened URL will be displayed on the screen.### Retrieve a URL
1. Enter the shortened key in the URL path (e.g., `http://localhost:8000/`).
2. You will be redirected to the original URL.📦 Dependencies
- Django
- Python 3.x
- Other dependencies listed in `requirements.txt`🔧 Configuration
### Database
By default, this project uses SQLite. You can configure other databases (e.g., PostgreSQL, MySQL) by updating the `DATABASES` setting in `settings.py`.📚 Documentation
### Views
- **getURL(request, key)**: Retrieves the original URL using the shortened key and renders a template for redirection.
- **createLink(request)**: Checks if there a corresponding key in the database for the input URL, if so, it returns the key, otherwise, it creates, stores and returns a new key.📬 API Endpoints
#### GET `/`
Home page to shorten URLs.#### GET `/create/`
Endpoint to handle URL shortening.#### GET `/{key}`
Endpoint to handle redirection to the original URL.### Jupyter Notebook
You can use this Jupyter Notebook to interact with the database using Django. For more info click [HERE](https://github.com/mmedoo/django-in-jupyter)❗️ Troubleshooting
### Common Issues
- **Server not starting**: Ensure all dependencies are installed and the database migrations have been applied.
- **Invalid URL**: Make sure the URL entered is valid and follows the correct format.