使用请求时如何为Flask-Restless构建复杂的过滤器?

时间:2015-07-23 14:32:39

标签: python flask python-requests flask-restless

我想使用Requests对Flask-Restless api进行复杂查询。我不确定如何使用请求构建以下query from the examples。如何进行此查询?

- (void)checkDisclaimer {
    UIStoryboard *storyboard = self.window.rootViewController.storyboard;

    if ([[[NSUserDefaults standardUserDefaults]valueForKey:@"disclaimerAcknowledged"]boolValue] == NO) {
        // set to instantiate disclaimer VC
        UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"disclaimer"];
        self.window.rootViewController = rootViewController;
        NSLog(@"Disclaimer IS NOT acknowledged");
    } else {
// this is the line that's working from a memory standpoint, but nothing happens
        UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"launchScreen"];
        self.window.rootViewController = rootViewController;
        NSLog(@"Disclaimer IS acknowledged");
    }
    [self.window makeKeyAndVisible];

}

1 个答案:

答案 0 :(得分:0)

Flask-Restless需要一个JSON格式的查询字符串。给出的示例是具有过滤器列表的字典,每个过滤器是另一个字典。构建您的查询结构,将其转储到JSON,然后使用请求进行查询。

import json
q = {'filters': [{'name': 'age', 'op': 'ge', 'val': 10}]}
r = requests.get('http://example.com', params={'q': json.dumps(q)})