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 %} |
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
#把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
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
class DataValidator(object): | |
def __init__(self, values, validators, force=False, callback=None): | |
self.values = values | |
self.validators = validators | |
self.callback = callback | |
self.force = force | |
def check(self): | |
values = self.values.copy() | |
for k, v in self.validators.items(): |
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
from uuid import uuid4 | |
from redis import StrictRedis | |
from functools import wraps | |
from datetime import datetime | |
from pytz import timezone | |
def singleton(cls): | |
instances = {} |
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
package main | |
import ( | |
"compress/gzip" | |
"flag" | |
"fmt" | |
"io" | |
"os" | |
) |
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
package main | |
import ( | |
"fmt" | |
"regexp" | |
"strings" | |
"testing" | |
) | |
var template = ` |
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
package main | |
import ( | |
"bytes" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"mime/multipart" | |
"net/http" | |
"os" |
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
package main | |
import ( | |
"testing" | |
) | |
type myStruct struct { | |
list []string | |
} |
OlderNewer