Skip to content

Instantly share code, notes, and snippets.

@dannyroa
Created July 8, 2013 05:05
Show Gist options
  • Save dannyroa/5946335 to your computer and use it in GitHub Desktop.
Save dannyroa/5946335 to your computer and use it in GitHub Desktop.
@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
if not name:
return "Please type a name"
#open shelve
filename = 'names.db'
d = shelve.open(filename)
#get names from shelve if it exists in shelve.
names = []
if d.has_key('names'):
names = d['names']
#add name to names list
names.append(name)
#put names list into shelve
d['names'] = names
#save & close shelve
d.close()
return 'Name has been saved to Shelve'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment