Giter Club home page Giter Club logo

url-shortener's Introduction

A simple URL Shortener

This is the code for the url shortener running at https://dre.li - it supports emoji urls ๐Ÿ’โ€โ™‚๏ธ

Requirements

  • A running MongoDB server

Config

The following config flags can be used:

Flag Environment Variable Default Description
--mongodb MONGODB "localhost/url-shortener" MongoDB Connection String
--port PORT 8000 Port on which the server listens
--admin-password ADMIN_PASSWORD foobar2342 Password for the /admin endpoint
--base-url BASE_URL "http://localhost:8000" Base URL for shorturls

Docker

Dockerfile is enclosed, a premade container will be available soon

Shorten URLs!

Do it either with the Webinterface located at the root, or

  • POST / with x-www-form-urlencoded value "url" set
  • POST / with query parameter ?url=

There is a second parameter, "emoji" if you set this to "1", it will create a shorturl using emojis.

Using it with other Software!

It is compatible with Software like dropshare. As default the shortener will assume a human is using this and render a HTML Page. If you are using the shortener together with other software you might want a different output. The shortener can render as text/html (default), application/json (a JSON representation of the shorturl) or text/plain (just the shorturl)

Example JSON output:

{
  "shorturl":"https://dre.li/4G4zKU",
  "url":"https://google.de",
  "manageurl":"https://dre.li/4G4zKU/xxxxx"
}

Just set the Accept Header accordingly. If for whatever reason it is not possible for you to set the Header correct, you can set the correct encoding in the "accept" value of either the Post Form or the Query Parameter.

url-shortener's People

Contributors

hennedo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.