示例#1
0
文件: weixin.py 项目: Jyonn/account
 def get_config(url):
     jsapi_ticket = Config.get_config_by_key(CI.WEIXIN_JSAPI_TICKET)
     noncestr = get_random_string(length=16)
     timestamp = int(datetime.datetime.now().timestamp())
     raw_string = 'jsapi_ticket=%s&noncestr=%s&timestamp=%s&url=%s' % (
         jsapi_ticket, noncestr, timestamp, url)
     signature = sha1(raw_string)
     return dict(
         noncestr=noncestr,
         signature=signature,
         timestamp=timestamp,
         appid=APP_ID,
     )
示例#2
0
    def post(r):
        tags = r.d.tags

        start = Config.get_config_by_key('start').body

        if tags == 'BACK':
            start.value = str(int(start.value) - 1)
        elif tags == 'DELETE':
            start.value = str(int(start.value) + 1)
        else:
            Phrase.create(**r.d.dict())
            start.value = str(int(start.value) + 1)

        start.save()

        return 0
示例#3
0
    def post(request):
        phrase = request.d.phrase
        tags = request.d.tags
        tags = str(tags)

        start = Config.get_config_by_key('start').body

        if tags == 'BACK':
            start.value = str(int(start.value) - 1)
        elif tags == 'DELETE':
            start.value = str(int(start.value) + 1)
        else:
            ret = Phrase.create(phrase, tags)
            if ret.error is not Error.OK:
                return error_response(ret)
            start.value = str(int(start.value) + 1)

        start.save()

        return response()
示例#4
0
 def get(request):
     start = int(Config.get_config_by_key('start').body.value)
     phrase = phrases[start]
     return response(phrase)