Example #1
0
def echo():
    # the api blueprint preprocesses request.data looking for a json.
    # if a valid json is put or posted, the results of json.loads can
    # be found in g.json, otherwise g.json = None
    from flask import g
    env = Envelope()
    if g.json:
       env.add_data(g.json)
    else:
       env.add_meta('code',400)
       env.add_meta('error_message',u'unable to process json')
    return env.send()
Example #2
0
def get_or_creat_api_key(user):
    if request.json is None: abort(400)
    if 'device_info' not in request.json: abort(400)
    device_info = request.json['device_info']
    verify_email = current_app.config.get('VERIFY_EMAIL', False)
    token = user.create_session(device_info, verify_email)
    assert token is not None
    # todo - handle the case where VERIFY_EMAIL is true
    identity_changed.send(current_app._get_current_object(), identity=Identity(token, auth_type='token'))
    envelope = Envelope(201)
    envelope.add_meta('token', token)
    envelope.add_data( to_safe_dict( user, 'basic_info' ) )
    return envelope.send()
Example #3
0
def super_secret():
    envelope = Envelope()
    envelope.add_meta('secret','shhhhh')
    return envelope.send()
Example #4
0
def not_so_secret():
    envelope = Envelope()
    return envelope.send()