Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Weixin for Flask.

Project Description

Flask-Weixin is the implementation for with the flavor of Flask. It can be used without Flask too.


You can install Flask-Weixin with pip:

$ pip install Flask-Weixin

Or, with setuptools easy_install in case you didn’t have pip:

$ easy_install Flask-Weixin

Getting Started

Eager to get started? It is always the Flask way to create a new instance:

from flask_weixin import Weixin

weixin = Weixin(app)

Or pass the app later:

weixin = Weixin()

However, you need to configure before using it, here is the configuration list:

  • WEIXIN_TOKEN: this is required
  • WEIXIN_SENDER: a default sender, optional
  • WEIXIN_EXPIRES_IN: not expires by default

For Flask user, it is suggested that you use the default view function:

app.add_url_rule('/', view_func=weixin.view_func)

def reply(**kwargs):
    username = kwargs.get('sender')
    sender = kwargs.get('receiver')
    content = kwargs.get('content')
    return weixin.reply(
        username, sender=sender, content=content

The example above will reply anything the user sent.

Message Types

Every message from weixin has these information:

  • id: message ID
  • receiver: which is ToUserName in the official documentation
  • sender: which is FromUserName in the official documentation
  • type: message type
  • timestamp: message timestamp

Text Type

Text type has an extra data: content.

Image Type

Image type has an extra data: picurl.

Location Type

Location type has extra data:

  • location_x
  • location_y
  • scale
  • label

Event Type

Event type has extra data:

  • event
  • event_key
  • latitude
  • longitude
  • precision

Voice Type

Event type has extra data:

  • media_id
  • format
  • recognition

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(8.2 kB) Copy SHA256 Hash SHA256
py2.py3 Wheel Nov 23, 2015
(6.9 kB) Copy SHA256 Hash SHA256
Source Nov 23, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting