Created
July 8, 2013 05:05
-
-
Save dannyroa/5946335 to your computer and use it in GitHub Desktop.
This file contains 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
@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