This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RestfulBase(object): | |
decorators = () | |
def __call__(self, func): | |
f = self.method(func) | |
if self.decorators: | |
for dec in reversed(self.decorators): | |
f = dec(f) | |
return f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#把datetime转成字符串 | |
def datetime_toString(dt): | |
return dt.strftime("%Y-%m-%d-%H") | |
#把字符串转成datetime | |
def string_toDatetime(string): | |
return datetime.strptime(string, "%Y-%m-%d-%H") | |
#把字符串转成时间戳形式 | |
def string_toTimestamp(strTime): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
today = datetime.datetime.today() | |
b = datetime.datetime(today.year, today.month, today.day, 0, 0, 0) | |
print(b) | |
now = time.time() | |
midnight = now - (now % 86400) + time.timezone | |
itime = time.ctime(midnight) | |
print(itime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro paginate(pagination, endpoint,kw=None) %} | |
<ul class="pagination" style="margin:0"> | |
{% if pagination.items and pagination.pages > 1 -%} | |
{%- if pagination.has_prev -%} | |
{%- if not kw -%} | |
<li><a href="{{ url_for(endpoint,page=pagination.page-1)}}" aria-label="Previous"><span aria-hidden="true">«</span></a></li> | |
{%- else -%} | |
<li><a href="{{ url_for(endpoint,page=pagination.page-1,**kw)}}" aria-label="Previous"><span aria-hidden="true">«</span></a></li> | |
{% endif -%} | |
{%- else %} |
NewerOlder