Created
September 28, 2012 05:33
-
-
Save AlecTaylor/3798093 to your computer and use it in GitHub Desktop.
REST code-golf
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
# models\choices.py | |
db.define_table( | |
'choice_list', | |
Field('choice', notnull=True, default='Yes', requires=IS_IN_SET(['Yes', 'Maybe', 'No'])) | |
) | |
# controllers\default.py | |
@service.json | |
def get_choices(): | |
return db(db.choice_list).select(db.choice_list.choice) | |
@service.json | |
def push_choice(): # also tried with arg here | |
return db.choice_list.validate_and_insert(choice=str(request.args(2))) | |
# URL `/call/json/push_choice/Yes` - WORKS! | |
# URL `/call/json/get_choices` - WORKS! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment