skip to navigation
skip to content

Not Logged In

Flask-Weixin 0.2.0

Weixin for Flask.

https://travis-ci.org/lepture/flask-weixin.png?branch=master https://coveralls.io/repos/lepture/flask-weixin/badge.png?branch=master

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

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

Get 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.

 
File Type Py Version Uploaded on Size
Flask-Weixin-0.2.0.tar.gz (md5) Source 2014-02-24 5KB
  • Downloads (All Versions):
  • 16 downloads in the last day
  • 56 downloads in the last week
  • 274 downloads in the last month