コード例 #1
0
ファイル: app.py プロジェクト: davewalk/Voter-ID-API
def getstate(statename):

    state_length = range(4, 15)

    if len(statename) == 2:
        state = db.states.find({'info.abbr': statename.upper()}, { '_id': False })
        return helpers.wrap_response(state)
    elif len(statename) not in state_length:
        message = 'That is not a recognizable value for a state.'
        return helpers.bad_request_response(message)
    else:
        state = db.states.find({'name': statename.title()}, { '_id': False })
        return helpers.wrap_response(state)
コード例 #2
0
ファイル: app.py プロジェクト: davewalk/Voter-ID-API
def getstates():
    filter = request.args.get('require', '')
    if (filter):
        if filter not in ('strict', 'id', 'photo'):
            message = ('%s is not a valid require value.  Use either strict, '
                'photo or id.' % filter)
            return helpers.bad_request_response(message)
        else:
            states = db.states.find({'vote.' + filter: True}, { '_id': False })
            return helpers.wrap_response(states)

    else:
        states = db.states.find({}, { '_id' : False })
        return helpers.wrap_response(states)