Skip to content

Instantly share code, notes, and snippets.

@gronnbeck
Created September 18, 2012 07:36
Show Gist options
  • Select an option

  • Save gronnbeck/3741809 to your computer and use it in GitHub Desktop.

Select an option

Save gronnbeck/3741809 to your computer and use it in GitHub Desktop.
from flask import Flask
import couchdb as couch
from uuid import uuid4
# set up db connection / a localhost connection
server = couch.Server()
db = server["short_url"]
# set up flask app
app = Flask(__name__)
@app.route("/s/<hash>")
def short_url:
obj = db[hash]
return redirect(obj.url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment