Skip to content

This Ruby-based project allows users to input long URLs and receive shortened versions. The web interface, built with Sinatra, also supports custom short codes and QR code generation for the shortened URLs. The project offers both a terminal-based tool for URL shortening and a web interface with stored URLs in YAML format.

Notifications You must be signed in to change notification settings

Albanovukelaj17/URL-shortener-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener with QR Code Generation

A simple URL shortener built with Sinatra, Ruby, and YAML for data storage. This project allows users to shorten URLs, create custom short codes, generate QR codes for shortened URLs, and track statistics such as the number of clicks and the last access time.

Features

-URL Shortening: Convert long URLs into short, easily shareable links.

-Custom Short Codes: Users can create custom short codes or let the system generate a random code.

-QR Code Generation: Generate a QR code for any shortened URL to easily share it with others.

-Statistics: View detailed statistics for each shortened URL, including click count and last access time.

-Persistent Storage: URLs and statistics are stored in a YAML file for persistence between server restarts.

Installation

Clone the repository:

git clone https://github.com/your-username/url-shortener.git

cd url-shortener Install the required dependencies:

bundle install

Start the Sinatra server:

ruby sinatra.rb

Open your browser and go to http://localhost:4567 to use the application.

Usage

Shorten a URL Enter a long URL in the input field and submit the form to generate a short URL. Optionally, provide a custom short code for the URL. QR Code After shortening a URL, a link to generate a QR code will be provided. The QR code can be used to quickly access the shortened URL. View Statistics You can view statistics for each shortened URL, such as the creation date, the last time it was accessed, and the number of clicks. Example 1.Shorten URL: You shorten https://example.com to http://localhost:4567/abc123. 2.QR Code: You get a QR code for http://localhost:4567/abc123. 3.Stats: View statistics for abc123 like clicks and last accessed time.

File Structure

-sinatra.rb: The main Sinatra application file that handles routing for the URL shortening service. It presents a webpage where users can: Choose from existing shortened URLs stored in the urls.yml file. Shorten new URLs by either using a randomly generated code or a custom code. Optionally view a QR code for the shortened URL.

-urls.yml: A YAML file used to store shortened URLs along with associated metadata such as click count, creation time, and last access time.

-Gemfile: Specifies the project's dependencies, including Sinatra, RQRCode, and YAML.

-README.md: Documentation for the project, including setup instructions and feature descriptions.

-main.rb: A Ruby script that provides terminal-based URL shortening and retrieval of long URLs, separate from the web interface.

Dependencies

-Ruby 2.7 or higher

-Sinatra

-RQRCode

-YAML

About

This Ruby-based project allows users to input long URLs and receive shortened versions. The web interface, built with Sinatra, also supports custom short codes and QR code generation for the shortened URLs. The project offers both a terminal-based tool for URL shortening and a web interface with stored URLs in YAML format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages