Example #1
0
    def get(self):
        image_path = 'static/qr_image/{session_id}.png'.format(
            session_id=self.session_id)
        self.wechat.get_qrcode(image_path)
        self.wechat.login(session, self.request)

        return render_json({'ok': 1, 'image_url': '/' + image_path})
Example #2
0
 def get(self, request):
     data = {
         'name': 'user_001',
         'company': 'Google',
         'department': 'Research and Development Department'
     }
     return render_json(data)
Example #3
0
    def post(self, request):

        # put user commit information for parameter, execute SQL INSERT statement put information save to database table
        ret = dbconn.insert('INSERT INTO user(f_name) VALUES (%(user)s)',
                            request.form)

        # if insert success, its means register success, redirect to login page
        if ret.suc:
            return redirect('/login')
        else:

            # if fail, put error information for debug
            return render_json(ret.to_dict())
Example #4
0
    def get(self):
        message_map = {
            '200': 'login success, redirect...',
            '201': 'please in your smartphone wechat app verification'
        }

        ok = int(self.session_map.get('status', 0))

        if self.session_map.get('status') == '200' and self.session_map.get(
                'is_login'):
            session.push(self.request, 'user',
                         self.wechat.storageClass.nickName)
            ok = 1

        return render_json({
            'ok':
            ok,
            'message':
            message_map.get(self.session_map.get('status'),
                            'please scan code login')
        })
Example #5
0
 def get(self):
     return render_json(self.wechat.get_friend_list())
Example #6
0
 def get(self):
     self.wechat.message_map['auto_replay'] = self.request.args.get(
         'msg', 'test auto replay')
     self.wechat.save_message_config()
     return render_json({'ok': 1})