Skip to main content

Flask-Weixin is the implementation for http://mp.weixin.qq.com/ with the flavor of Flask. It can be used without Flask too.

Wheel Status Latest Version Travis CI Coverage Status

Installation

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()
weixin.init_app(app)

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)

@weixin.register('*')
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

Metadata

Release files for Flask-Weixin 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-Weixin 0.5.0
File Size Uploaded Provenance
Flask-Weixin-0.5.0.tar.gz 6.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-Weixin 0.5.0
File Interpreter ABI Platform
Flask_Weixin-0.5.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.1 kB

Release files / Flask-Weixin-0.5.0.tar.gz

Download URL Flask-Weixin-0.5.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
02a1322db3917e79aaae9bc9d08228ee68abfa9c813cc3193b7a5a675fe45436
BLAKE2b-256 checksum
How to use checksums
ca4f284c1bfa88442e65f350137d42cd12dc411321387bde1fd812a84df1a335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / Flask_Weixin-0.5.0-py2.py3-none-any.whl

Download URL Flask_Weixin-0.5.0-py2.py3-none-any.whl
Size 8.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
29487d678e1f45b039779e7ba61a95645e4c83bd7b0118ff828b4a12f9afb5c0
BLAKE2b-256 checksum
How to use checksums
4d06777e890737fae0046a1e384cc9b9a9a5d5b936dfb2270e45aa3904678b70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for Flask-Weixin 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page