Пример #1
0
def twisks():
    """Returns all twisks in JSON format. All of them."""
    if request.method == 'GET':
        twisks = Twisk.gql("ORDER BY when DESC LIMIT 20")
        return twisks
    elif request.method == 'POST':
        logging.debug(request.data)
        data = json.loads(request.data)

        twisk = Twisk(
            author=ndb.Key("TwiskUser", data['author']),
            content=data['content']
        )

        twisk.put()

        return twisk
Пример #2
0
def show_user(username):
    """Shows all the twisks posted by a given user"""
    twisks = Twisk.gql("WHERE author = :1 ORDER BY when DESC LIMIT 50",
                       ndb.Key(TwiskUser, username))
    return render_template("list_twisks.html", twisks=twisks)