8000 GitHub - MHamzaImran/url_shortener: A simple and efficient URL shortener built with Django. This project allows users to shorten long URLs into compact, shareable links. Hosted on Google Cloud Run with a NeonDB PostgreSQL database, it ensures scalability and reliability.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A simple and efficient URL shortener built with Django. This project allows users to shorten long URLs into compact, shareable links. Hosted on Google Cloud Run with a NeonDB PostgreSQL database, it ensures scalability and reliability.

Notifications You must be signed in to change notification settings

MHamzaImran/url_shortener

Repository files navigation

TheURLShortener

A simple and efficient URL shortener built with Django, deployed on Google Cloud Run, and using Neon as a database in production.

Features

  • Shorten long URLs into concise links
  • Redirect users from short links to original URLs
  • Simple admin panel for managing URLs
  • SQLite for local development and Neon for production database

Tech Stack

  • Backend: Django 5
  • Database: SQLite (local), Neon (production)
  • Deployment: Google Cloud Run
  • Environment Management: Python dotenv

Installation & Setup

Prerequisites

  • Python 3.x installed
  • Virtual environment setup

Steps

  1. Clone the repository:
    git clone https://github.com/MHamzaImran/url_shortener.git
    cd url_shortener
  2. Create a virtual environment and activate it:
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Set up environment variables: Create a .env file and add the following:
    SECRET_KEY=<your-secret-key>
    DEBUG=True  # Set to False in production
    DATABASE_URL=<your-neon-database-url>
    PORT=8080
  5. Apply migrations:
    python manage.py migrate
  6. Run the server:
    python manage.py runserver

Deployment (Google Cloud Run)

  1. Build and push Docker image:
    gcloud builds submit --tag gcr.io/<your-project-id>/theurlshortener
  2. Deploy to Cloud Run:
    gcloud run deploy theurlshortener --image gcr.io/<your-project-id>/theurlshortener --platform managed --region us-central1 --allow-unauthenticated

Security Considerations

  • SECRET_KEY: Never expose your secret key in public repositories.
  • DEBUG Mode: Set DEBUG=False in production to prevent security vulnerabilities.
  • ALLOWED_HOSTS: Restrict it to your domain in production.

License

This project is open-source under the MIT License.

Contact

For any queries, feel free to reach out to: Muhammad Hamza Imran
LinkedIn | GitHub | Portfolio

About

A simple and efficient URL shortener built with Django. This project allows users to shorten long URLs into compact, shareable links. Hosted on Google Cloud Run with a NeonDB PostgreSQL database, it ensures scalability and reliability.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published
Packages
No packages published
0