Exemplo n.º 1
0
def ajaxonly(f):
    f = csrf_exempt(f)
    @wraps(f)
    def decorated(*args, **kwargs):
        if not request.is_xhr:
            return "Bad Request", 400
        return f(*args, **kwargs)
    return decorated
Exemplo n.º 2
0
def ajaxonly(f):
    f = csrf_exempt(f)

    @wraps(f)
    def decorated(*args, **kwargs):
        if not request.is_xhr:
            return "Bad Request", 400
        return f(*args, **kwargs)

    return decorated
Exemplo n.º 3
0
# -*- coding: utf-8 -*-


from flask import Blueprint
from flaskext.csrf import csrf_exempt

from views.weixin.weixin import WeiXin

weixin = Blueprint('weixin', __name__)

weixin_view = WeiXin.as_view('weixin')
weixin.add_url_rule('/', view_func=weixin_view, methods=['GET'])
weixin.add_url_rule('/', view_func=csrf_exempt(weixin_view), methods=['POST'])

Exemplo n.º 4
0
#!/usr/local/bin/python2.7
#coding:utf-8

from flask import Blueprint
from flaskext.csrf import csrf_exempt

from views.topic.view import View
from views.topic.index import Index
from views.topic.delete import Delete
from views.topic.reply import CreateReply
from views.topic.topic import CreateTopic

topic = Blueprint('topic', __name__)

view = View.as_view('view')
index = Index.as_view('index')
delete = Delete.as_view('topic_delete')
create_reply = csrf_exempt(CreateReply.as_view('create_reply'))
create_topic = csrf_exempt(CreateTopic.as_view('create_topic'))

topic.add_url_rule('/', view_func=index, methods=['GET'])
topic.add_url_rule('/view/<int:tid>/', view_func=view, methods=['GET'])
topic.add_url_rule('/delete/<int:tid>/', view_func=delete, methods=['GET'])
topic.add_url_rule('/reply/<int:tid>/', view_func=create_reply, methods=['GET', 'POST'])
topic.add_url_rule('/create/<int:uid>/', view_func=create_topic, methods=['GET', 'POST'])

Exemplo n.º 5
0
#!/usr/local/bin/python2.7
#coding:utf-8

from flask import Blueprint
from flaskext.csrf import csrf_exempt

from views.account.forget import Forget, Reset
from views.account.setting import Setting, Avatar
from views.account.bind import OauthBind, WeixinBind
from views.account.account import Register, Login, Logout

account = Blueprint('account', __name__)

reset = Reset.as_view('reset')
forget = csrf_exempt(Forget.as_view('forget'))

avatar = Avatar.as_view('avatar')
setting = Setting.as_view('setting')

oauth_bind = OauthBind.as_view('bind')
weixin_bind = WeixinBind.as_view('weixin_bind')

login = csrf_exempt(Login.as_view('login'))
logout = csrf_exempt(Logout.as_view('logout'))
register = csrf_exempt(Register.as_view('register'))

account.add_url_rule('/login/', view_func=login, methods=['GET', 'POST'])
account.add_url_rule('/register/', view_func=register, methods=['GET', 'POST'])
account.add_url_rule('/logout/', view_func=logout, methods=['GET'])

account.add_url_rule('/forget/', view_func=forget, methods=['GET', 'POST'])