Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/isundaylee/short_url
A simple implementation of URL shortener built with Sinatra and Redis.
https://github.com/isundaylee/short_url
Last synced: 29 days ago
JSON representation
A simple implementation of URL shortener built with Sinatra and Redis.
- Host: GitHub
- URL: https://github.com/isundaylee/short_url
- Owner: isundaylee
- Created: 2015-07-25T04:55:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T20:50:50.000Z (almost 2 years ago)
- Last Synced: 2023-03-23T01:52:10.448Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 1.52 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Short URL [![Build Status](https://travis-ci.org/isundaylee/short_url.svg?branch=master)](https://travis-ci.org/isundaylee/short_url)
A simple implementation of URL shortener built with Sinatra with a Redis backend.
# Installation
To run this URL shortener, you need to first [set up a Redis server](http://redis.io/topics/quickstart). After that, you can start it as you would any other Rack app:
```bash
git clone https://github.com/isundaylee/short_url.git
rackup -p 3000 # start it on port 3000
```# Usage - HTML (browser)
A demo of this app can be found at http://jiahao.link
To create short URLs, simply go to `http://yoursite.com`. You can both create short URLs with custom names or ones with automatically generated names.
To access a short URL, simply visit `http://yoursite.com/name` (which is also returned to you in JSON after you created the short URL), and you will be redirected to the actual URL.
# Usage - JSON REST
To create a short URL (you can also omit the name parameter to get a randomly generated name that could be as short as 2 characters):
```
POST /Params: {'name': 'google', 'url': 'http://google.com'}
Response: {'url': 'http://example.com/google'}
```To retrieve the actual URL:
```
GET /googleResponse: {'actual_url': 'http://google.com'}
```# Contribution
If you wanna contribute to this app, you can [create issues](https://github.com/isundaylee/short_url/issues), or submit a pull request as follows:
1. Fork it.
2. Create a branch (`git checkout -b new_feature`)
3. Commit your changes (`git commit -am "Implements an awesome feature. "`)
4. Push to the branch (`git push origin new_feature`)
5. Open a [pull request](https://github.com/isundaylee/short_url/pulls)
6. Wait, while feeling good for your contribution :)