Skip to main content

微信小程序Flask扩展

Installation

pip install Flask-WXApp

Configuration

Your configuration should be declared within your Flask config.

WX_APPID = 'your appid'
WX_SECRET = 'your app secret'

Create instance within your application

from flask import Flask
from flask_wxapp import WXApp

wxapp = WXApp()

def create_app():
    app = Flask(__name__)
    wxapp.init_app(app)
    return app

Usage

  • 通过code换取openid和session_key

接口:

wxapp.jscode2session(js_code)

返回json(dict):

参数

说明

openid

用户唯一标识

session_key

会话密钥

  • 加密数据解密

接口:

wxapp.decrypt(session_key, encrypted_data, iv)

返回数据如下:

{
    'avatarUrl': 'http://wx.qlogo.cn/mmopen/vi_32/aSKcBBPpibyKNicHNTMM0qJVh8Kjgiak2AHWr8MHM4WgMEm7GFhsf8OYrySdbvAMvTsw3mo8ibKicsnfN5pRjl1p8HQ/0',
    'city': 'Guangzhou',
    'country': 'CN',
    'gender': 1,
    'language': 'zh_CN',
    'nickName': 'Band',
    'openId': 'oGZUI0egBJY1zhBYw2KhdUfwVJJE',
    'province': 'Guangdong',
    'unionId': 'ocMvos6NjeKLIBqg5Mr9QjxrP1FA',
    'watermark': {'appid': 'wx4f4bc4dec97d474b', 'timestamp': 1477314187}
}
  • 生成3rd_session的key

wx.gen_3rd_session_key()

返回32位长度的16进止字符串,例如:

8e4792ee728926443147bb5703aa50a7

Metadata

Release files for Flask-WXApp 0.1.3

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-WXApp 0.1.3
File Size Uploaded Provenance Actions
Flask-WXApp-0.1.3.tar.gz 2.6 kB Without provenance Details for Flask-WXApp-0.1.3.tar.gz

Release files / Flask-WXApp-0.1.3.tar.gz

Download URL Flask-WXApp-0.1.3.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c530f0d1453e5ba115a70e84e981b1d95ff5ffa2cbd523df5bbf98714fc79e49
BLAKE2b-256 checksum
How to use checksums
c660148cecd36dc455214686ef78be0a023eae03c6daded071b532957cc8fa36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Security for Flask-WXApp 0.1.3

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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