A simple implementation of URL shortener built with Sinatra and Redis.
254
A simple implementation of URL shortener built with Sinatra with a Redis backend.
To run this URL shortener, you need to first set up a Redis server. After that, you can start it as you would any other Rack app:
git clone https://github.com/isundaylee/short_url.git
rackup -p 3000 # start it on port 3000
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.
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 /google
Response: {'actual_url': 'http://google.com'}
If you wanna contribute to this app, you can create issues, or submit a pull request as follows:
git checkout -b new_feature)git commit -am "Implements an awesome feature. ")git push origin new_feature)Content type
Image
Digest
Size
140.2 MB
Last updated
over 5 years ago
docker pull isundaylee/short_url