예제 #1
0
#!/usr/bin/env python
# encoding: utf-8

from flask import Flask, request, session
from flask_wechatpy import Wechat, wechat_required, oauth
from wechatpy.replies import TextReply
from wechatpy.replies import create_reply

app = Flask(__name__)
app.config['WECHAT_APPID'] = 'wx186958a84617e867'
app.config['WECHAT_SECRET'] = '12e75aabd90ab2e034941f61f0c8d0aa'
app.config['WECHAT_TOKEN'] = 'token'
app.config['DEBUG'] = True
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

wechat = Wechat(app)


@app.route('/')
@oauth(scope='snsapi_userinfo')
def index():
    return "hello"


@app.route('/clear')
def clear():
    if 'wechat_user_id' in session:
        session.pop('wechat_user_id')
    return "ok"

예제 #2
0
파일: extensions.py 프로젝트: hengke/school
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from flask_wtf.csrf import CSRFProtect
from flask_wechatpy import Wechat
from flask_bootstrap import Bootstrap
# from flask_mail import Mail
# from flask_apscheduler import APScheduler

import logging

bcrypt = Bcrypt()
csrf_protect = CSRFProtect()
login_manager = LoginManager()
db = SQLAlchemy()
migrate = Migrate()
cache = Cache()
debug_toolbar = DebugToolbarExtension()
wechat = Wechat()
bootstrap = Bootstrap()
# mail = Mail()
# scheduler = APScheduler()

login_manager.session_protection = 'basic'

#自动注册
login_manager.login_view = 'auth.autologin'
login_manager.login_message = u"请登录后访问该页面."
login_manager.refresh_view = 'auth.autologin'