Skip to content

Instantly share code, notes, and snippets.

@r3bo0t
Created August 16, 2013 06:13
Show Gist options
  • Save r3bo0t/6247669 to your computer and use it in GitHub Desktop.
Save r3bo0t/6247669 to your computer and use it in GitHub Desktop.
Simplest code for url shortener application with Bottle
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