GithubHelp home page GithubHelp logo

thienh0 / url-shortener Goto Github PK

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

URL Shortener is a simple and efficient web service for transforming long and unwieldy URLs into concise, user-friendly links. It provides a convenient way to create, manage, and access shortened URLs.

License: MIT License

Go 100.00%

url-shortener's Introduction

URL Shortener

URL Shortener is a simple and efficient web service for transforming long and unwieldy URLs into concise, user-friendly links. It provides a convenient way to create, manage, and access shortened URLs.

Features:

  • Shorten long URLs with a single API call.
  • Redirect users to the original URL using the shortened link.
  • Securely store URL mappings in a SQLite database.
  • Generate unique, six-character short aliases for each URL.
  • Error handling and validation to ensure a smooth user experience.

Getting Started

Prerequisites:

  • Go programming language
  • SQLite database

Installation:

  1. Clone this repository:

    git clone https://github.com/ThienH0/url-shortener.git cd url-shortener

  2. Initialize the SQLite database:

    sqlite3 url-shortener.db

  3. Build and run the project:

    go build go run

The URL Shortener service will start on http://localhost:8080.

Usage

Shorten a URL:

To shorten a URL, make a POST request to the /shorten endpoint with the longURL parameter:

curl -X POST -d "longURL=https://www.example.com" http://localhost:8080/shorten

You will receive a JSON response with the shortened URL:

{"shortURL":"Ff5ypq"}

Access a Shortened URL:

To access a shortened URL, simply enter it in your browser's address bar, e.g., http://localhost:8080/Ff5ypq. You will be redirected to the original URL.

Database Schema

The project uses an SQLite database to store URL mappings. The schema consists of a single table named urls with the following structure:

  • id: Integer, primary key
  • short: Text, the short URL
  • long: Text, the original URL

Contributing

Contributions are welcome! If you have suggestions, feature requests, or found a bug, please open an issue or create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

url-shortener's People

Contributors

thienh0 avatar

Watchers

 avatar

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.