Skip to content

Instantly share code, notes, and snippets.

@AlecTaylor
Created September 28, 2012 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlecTaylor/3798093 to your computer and use it in GitHub Desktop.
Save AlecTaylor/3798093 to your computer and use it in GitHub Desktop.
REST code-golf
# 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