3.6 配置文件拆分
@classmethod
def search_by_key(cls, q, count=15, start=0):
url = cls.search_by_key_url.format(q, count, start)
return HTTP.get(url)...
...
# flask提供了获取当前app的方法
from flask import current_app
...
...
@classmethod
def search_by_key(cls, q, page=1):
url = cls.search_by_key_url.format(q, current_app.config["PRE_PAGE"],
cls.calculate_start(page))
return HTTP.get(url)
@staticmethod
def calculate_start(page):
return (page-1) * current_app.config["PRE_PAGE"]Last updated
Was this helpful?