本文整理汇总了Python中main.PageData.page方法的典型用法代码示例。如果您正苦于以下问题:Python PageData.page方法的具体用法?Python PageData.page怎么用?Python PageData.page使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main.PageData
的用法示例。
在下文中一共展示了PageData.page方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from main import PageData [as 别名]
# 或者: from main.PageData import page [as 别名]
def search():
"""
:URL: /item/search?page=<page>&type=<query type>&limit=<max results>&query=<search query>&sort=<sort type>
:Method: GET
:Query Types:
* item - Item Search
* user - User Search
:Sort Types:
* name - Alphabetical by name
* added - By added date, latest first
* modified - Last modified
:Sample Response: Setting the accept:application/json header will return JSON.
.. code-block:: javascript
{
"limit": 2,
"num_pages": 4,
"num_results": 8,
"query": "Cascadia",
"results": [
{
"added": "2016-05-22 17:52:36",
"body": "Blue/White (Cascadia Fringe, Gisele Currier Memorial Fundraiser)",
"description": 460,
"images": [
388,
389
],
"modified": "2016-05-24 22:45:33",
"name": "No Pity MLS Blue White Fringe (Cascadia Fringe) 2012",
"uid": 362
},
{
"added": "2016-05-22 17:02:15",
"body": "",
"description": 317,
"images": [
364,
365
],
"modified": "2016-05-22 17:02:15",
"name": "Cascadia",
"uid": 350
}
]
}
"""
pd = PageData()
pd.search_type = request.args.get('type')
pd.query = request.args.get('query')
pd.limit = request.args.get('limit')
pd.page = request.args.get('page')
pd.sort = request.args.get('sort')
try:
if not pd.limit:
pd.limit = 20
else:
pd.limit = int(pd.limit)
if not pd.page:
pd.page = 1
else:
pd.page = int(pd.page)
except ValueError:
return page_not_found()
if pd.search_type == "items":
return item_search(pd)
elif pd.search_type == "users":
return user_search(pd)
elif pd.search_type == "tags":
return tag_search(pd)
else:
pd.search_type = "items"
return item_search(pd)