Giter Site home page Giter Site logo

eslam5464 / url-shortener Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 85 KB

Simple web application to shorten URLs locally or on a server

License: MIT License

Python 86.52% Mako 1.16% Batchfile 3.28% Dockerfile 2.02% HTML 4.42% CSS 1.73% JavaScript 0.87%
fastapi postgresql python3 redis sqlalchemy

url-shortener's Introduction

MIT License LinkedIn Github

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contributing
  4. License
  5. Contact

About The Project

  • The project aims to build a URL shortener service that takes long URLs and generates shortened versions, making them easier to share
  • Users can input long URLs, and the system will generate a unique short URL for each input

Sample image

Sample image

Technologies Used

Python FastApi PostgreSQL Redis Jinja HTML CSS JavaScript

  • Python: The primary programming language for backend development.
  • FastAPI: To create the web service and handle HTTP requests/responses.
  • PostgreSQL: As the primary database to store information about original URLs and their corresponding short URLs.
  • Redis: To cache frequently accessed URLs for faster retrieval and better performance and use it for the api limiter to limit requests.
  • Jinja2 Template Engine: To render HTML templates for the frontend interface.
  • HTML/CSS/JavaScript: For the frontend interface.

Note: each of the above icons redirects to its official documentation

(back to top)

Getting Started

Prerequisites

Installation

  1. Clone the repo
    git clone https://github.com/eslam5464/Url-Shortener.git
Environment variables
BACKEND_HOST=127.0.0.1
BACKEND_PORT=8000

CORS_ORIGIN=["*"]

ALLOWED_HOSTS=["*"]

POSTGRES_DB=main-database
POSTGRES_DB_SCHEMA=url-shortener
POSTGRES_HOST=localhost
POSTGRES_PASSWORD=change-this
POSTGRES_PORT=5432
POSTGRES_USER=postgres

REDIS_HOST=localhost
REDIS_USER=
REDIS_PASS=change-this
REDIS_PORT=6379

Local

  1. Add the previous environment variables to your project
  2. Create a new virtual environment Official python website documentation
  3. Activate the virtual environment
  4. Change the directory to 'backend' folder e.g. cd backend, and then run the following commands
pip install poetry poetry-plugin-export
poetry config virtualenvs.create false
poetry export --without-hashes -f requirements.txt -o requirements.txt
pip install --upgrade pip
pip install -r requirements.txt
python main.py

Docker

  1. Add the environment variables from above in the shell
  2. Change directory to project root directory and run dockerfile
docker-compose -f docker-compose-local.yml -p url-shortener up -d --build backend
  1. You should see the web interface at http://localhost:8000 or the port and host that you specified in the environment variables.*

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See the file LICENSE for more information.

(back to top)

Contact

Project Link: GitHub

Social: LinkedIn

(back to top)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.