Code Monkey home page Code Monkey logo

lilshorty's Introduction

LilShorty

A simple URL shortener built with Go and MongoDB.

Requirements

  • Go (v1.16 or higher)
  • MongoDB

Installation

  1. Clone the repository:
git clone https://github.com/cchhaarroonn/LilShorty.git
  1. Change to the project directory:
cd LilShorty
  1. Initialize project and get dependencies:
go mod init <charon/lilshorty>
go get github.com/gin-gonic/gin
go get go.mongodb.org/mongo-driver/mongo
  1. Set up MongoDB by creating a database and a collection. Update the MongoDB connection URL in the code:
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://<username>:<password>@<host>:<port>")) <line 22>

Usage

  1. Run the application:
go run main.go
  1. The server will start running on locahost:42069 by default change it on line 127

Shortening a URL

Send a POST request to /createShort/:url to shorten a URL. Replace :url with the actual URL you want to shorten.

POST /createShort/http://example.com
{
  "status": "URL shortened, key is: <generated-key>"
}

Redirecting to the Original URL

GET /short/<generated-key>
{
  "status": "<original-url>"
}

Contributing

Contributions are welcome! If you find any issues or want to add new features, please open an issue or submit a pull request.

Note

As always there is a note lmao ... I might make website for this like basic html, css, js but it really depends if I want to burn my brain at some point until then just enjoy using this simple thingy it is not much but is quite good

lilshorty's People

Contributors

cchhaarroonn avatar

Stargazers

 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.