Created
August 16, 2013 06:13
-
-
Save r3bo0t/6247669 to your computer and use it in GitHub Desktop.
Simplest code for url shortener application with Bottle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gdshortener | |
from bottle import route, run, request | |
@route('/ping') | |
@route('/') | |
def index(): | |
return ''' | |
<form action="/url_shortener" method="post"> | |
URL : <input name="url" type="text" /> | |
<input value="Convert" type="submit" /> | |
</form> | |
''' | |
@route('/url_shortener', method='POST') | |
def url_shortener(): | |
s = gdshortener.ISGDShortener() | |
url = s.shorten(request.forms.get('url'))[0] | |
return("Short URL: <a href='" + url + "'>" + url) | |
def ping(name= "google.com"): | |
return("Hello World!") | |
run(host='localhost', port=8080, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment