Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A demo of how to show itchat qrcode through website.
import threading
from flask import Flask, make_response
import itchat
qrSource = ''
def start_flask():
flaskApp = Flask('itchat')
def return_qr():
if len(qrSource) < 100:
return qrSource
response = make_response(qrSource)
response.headers['Content-Type'] = 'image/jpeg'
return response
flaskThread = threading.Thread(target=start_flask)
def qrCallback(uuid, status, qrcode):
if status == '0':
global qrSource
qrSource = qrcode
elif status == '200':
qrSource = 'Logged in!'
elif status == '201':
qrSource = 'Confirm'
itchat.auto_login(True, qrCallback=qrCallback)
def reply_text(msg):
return msg['Text']

This comment has been minimized.

Copy link

@jjuu jjuu commented May 27, 2018


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment